Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Message-Id: <5.1.0.14.2.20021020080704.01fdb3a0@pop3.cris.com>
X-Sender: rrschulz@pop3.cris.com
Date: Sun, 20 Oct 2002 08:13:11 -0700
To: Andrew Ellerton <ellers@iinet.net.au>,
   Sven =?iso-8859-1?Q?K=F6hler?=
  <skoehler@upb.de>
From: Randall R Schulz <rrschulz@cris.com>
Subject: Re: Cygwin Here power toy
Cc: cygwin@cygwin.com
In-Reply-To: <DB883JGTOHE2YGDC92WYSRLMLWQJGP.3db2b676@milano>
References: <3DB2B34F.2050302@upb.de>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed

Andrew,

At 06:58 2002-10-20, Andrew Ellerton wrote:
> >> @="c:\\cygwin\\bin\\bash.exe --login -c \"cd '%1' ; exec /bin/bash 
> -rcfile ~/.bashrc\""
> >
> >can you think of any better way to start bash?
> >the above creates two bash.exe in memory:
> >one executing /etc/profile and the cd-command
> >and one showing the prompt.
>
>The first shell executes a single line of shell commands, namely to change 
>directory and run another shell. The second shell runs as the "normal" 
>interactive shell. Net effect - looks like the shell has started in a 
>different directory. Admittedly a bit hacky, having two shells running for 
>no good reason, but it does the job. I'm not sure if shells are very 
>expensive in terms of memory. If not, then its a bit kludgey, but 
>otherwise its ok.

There are not (ever) two shells running as a result of invoking this 
command string. The second one overlays the first in the same process. 
That's what the "exec" built-in of the shells does.

Note that the directory name expanded as "~" is $HOME. If $HOME is not set, 
"~" expands to the empty string. The "~userName" syntax consults the 
password file, so it still works even in the absence of a $HOME variable.


> >bash --login -c "command"
> >exits after executing the command.
> >is there any bash-internal command, that let's you show a prompt after
> >the command is executed? or any switch that forces bash to not exit?
>
>There's bound to be... anyone got any idea? I saw another posting to the 
>list where the cd gets written to a file then the login script looks for 
>the file and changes to that dir... that's an option.

Avail yourself of environment variables.


>Andrew


Randall Schulz
Mountain View, CA USA


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

