CD doesn't work in script

Igor Peshansky
Thu May 3 16:31:00 GMT 2007

On Thu, 3 May 2007, SCHLING wrote:

> Hi all,
> I have successfully installed Cygwin on XP SP2, and would like to run a
> script which includes a change directory command (cd \etc.)
> All the other lines of the script work except the one with cd. The same
> line works when input by hand.
> Searching on the net I found that line endings could be critical (Lf
> instead of CrLf) and ran the script through d2u. Still no success.
> Curiously, if the script tries a cd with a non-existing directory, I get
> a warning. Otherwise, the script runs withouth any problems, but the
> active directory does not change.
> Don't know what to do next...

The first thing to do is to try the same script on Linux -- I suspect this
is not a Cygwin-specific problem.

One WAG is that the cd does happen, but in a subprocess (e.g.,
parenthesized command, or part of a pipe), so that the main bash process
does not see the change in directory.  If that is the case, see a bash
scripting guide for possible fixes (this is the same problem as setting
environment variables in subprocesses).  Again, this is not
      |\      _,,,---,,_ |
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Freedom is just another word for "nothing left to lose"...  -- Janis Joplin

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list