[ale] Bash scripts for idiots...

Jacob Langseth jwl at pobox.com
Fri Nov 5 22:46:03 EST 1999


Benjamin Scherrey scribed:
> --- snip ---
> # !/bin/sh
> cd ~/develop/src
> dir
> --- snip ---
> 
> When run from my home directory, it will change to the directory and
> give me the proper listing but, upon exit of the script, I'm still in
> my home directory. What stupid option am I missing from my bash
> script?
> 
> 	thanx & later,
> 
> 		Ben "I'm a programmer not a sysadmin!" Scherrey

The script is executed by the command specified
by the #! line at the top, which results in a
seperate process.  The current working directory
is updated in the child process, but not in the
parent (your shell), hence the directory is
not retained upon exit.

The solution is to interpret the commands w/in
the current shell.  The easiest way to do this
is to use an alias, such as:

 $ alias work="cd ~/develop/src; dir"

Hope this helps,
    Jacob






More information about the Ale mailing list