arguments for a command file

Barry Gold lcc.barry at UCLA-LOCUS.ARPA
Sat Dec 22 08:29:41 AEST 1984


Sorry for posting this; usual problem with munged return address.

cd is a built-in command to the shell.  It changes the current working
directory of the shell's process.  It MUST be built-in; if it were fork/exec'ed
like normal commands it would change the working dir of only the child process.

When you execute a command file, a new shell is created in a child process to
interpret the commands.  The cd command affects this child process's cwd, but
leaves the parent process (YOUR shell), unaffected.  That's why your command
file behaves so strangely.

If you use the c-shell, try something like:

alias change "set x = \!\$; source changescript"

Then change xx will cause the script to run in YOUR shell, not a child process,
and the cd command will take effect as you desire.  Of course, changescript
must refer to $x instead of $1.

barry



More information about the Comp.unix.wizards mailing list