This is the mail archive of the
mailing list for the Cygwin project.
Re: Executing bash commands from the bash command line
- From: Michael Beach <michaelb at ieee dot org>
- To: "Hamish Fawns" <fawnha at aie dot act dot edu dot au>, <cygwin at cygwin dot com>
- Date: Thu, 1 Aug 2002 18:24:19 +1000
- Subject: Re: Executing bash commands from the bash command line
- References: <004101c23925$9d5f5900$9701320a@flareon> <0208011650160J.13014@gilgamesh> <006501c2392b$29e5faf0$9701320a@flareon>
On Thursday 01 August 2002 17:15, Hamish Fawns wrote:
> > bash -c "cd /cygdrive/c/myfolder ; exec bash"
> Dear George,
> I did as you suggested however when I called "exec bash" after changing
> the directory a new instance of bash was spawned but when a new instance of
> bash was spawned it started in my home directory (~).
Hmm, who the hell is George?
All I can suggest here is that perhaps your bash thinks it is a login shell,
and so is processing commands from /etc/profile. I believe the standard
/etc/profile includes a line which cd's to the user's home directory.
Presumably you want a bash started in such a way to actually be a login
shell. What I would suggest is supplying an alternate start up file to bash
which just sources the standard ones and then cd's to the directory you want
afterwards. The name of the directory can be passed to the cd via an
environment variable which is set before you invoke the shell in the first
place. The alternative is to just substitue your own startup script which
does what /etc/profile does but doesn't fool with the current directory, but
this then means that you've effectively cut and pasted large chunks of
/etc/profile to create your own startup script, with all the associated
problems of tracking changes etc.
I would also suggest reading the bash man page. This, along with reading
/etc/profile and any other bash startup files in your home dir, will answer
ALL questions of the form "Why does bash do XYZ when I start it with command
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html