Using cd in scripts


Subject: Using cd in scripts
From: Josh Smith (irilyth@infersys.com)
Date: Thu Jun 15 2000 - 10:08:47 MDT


This isn't really a Yellow Dog specific thing, but anyway:

Each process on the system has an idea of its current working directory
(CWD). The 'cd' command changes the CWD of the current process. So, when you
run a shell script (or a Perl script, or whatever) that changes your CWD, it
changes it within the context of that process, and when that process exits,
and you return to the shell, the value of the CWD in the shell process (from
which you ran the shell script, or Perl program, or whatever) hasn't changed
(because nothing has changed it).

An alias might do what you want, e.g.

  alias gotmp='cd /var/tmp'

That doesn't start a new process when it runs, so it changes your CWD in the
context of the shell in which you run it. Make sense?

                                      -Josh (irilyth@infersys.com)



This archive was generated by hypermail 2a24 : Thu Jun 15 2000 - 10:11:08 MDT