This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Executing bash commands from the bash command line

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 
line PQR".

>     Hamish


Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]