I am running (I believe) the latest stable version of cygwin
CYGWIN_NT-5.1 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
on a win xp sp2 laptop.
Suppose, to make things simple for now (but I may do a part 2 posting...), that I am in a dos shell, and I want to create a bash shell and have it execute a few commands before closing and returning to the dos prompt.
I have experimentally found that this (dos) command line does the trick:
c:\cygwin\bin\bash.exe --login -c "pwd && ls -a"
It outputs
/home/BKernigan
. .. .bash_history .bash_profile .bashrc .inputrc
as expected, and then closes and returns to dos. Note that the working directory is my home directory, /home/BKernigan, and that its contents (all bash related config files) are correctly listed.
This (dos) command line
c:\cygwin\bin\bash.exe -i -c "pwd && ls -a -l"
(same as above except that -i replaces --login) partially works; it outputs
/cygdrive/d/unix/nextVersion/script
bash: ls: command not found
Here, it thinks that the working directory is the directory where I created the dos shell (d:\unix\nextVersion\script), as opposed to my cygwin home, so that is one difference from the --login version. And then, for some bizarre reason, the ls command is not found! Hmm, how can it find the pwd command but not ls? Note that the ls command really is in my cygwin installation (this is known both because the ls command in the first example worked, and I can also assure you that ls.exe is found in C:\cygwin\bin).
Does anyone have any idea what is going on here???
The web research that I did does not seem to answer this question. (The best single reference being the generic bash reference
Bash Reference Manual: Invoking Bash, but I found it to be quite complex.)
Forgive me in advance if this is such an obvious error on my part.
Also, if this is not the best forum--or even the best website--for this question, by all means suggest to me where I should go and I will repost it there.