[svlug] Shell scripting is biting me! :)
nate at wired.com
Tue Sep 18 16:54:01 PDT 2001
On Tue, Sep 18, 2001 at 03:38:08PM -0700, Ivan Passos wrote:
> I have a project src tree that is similar to the one below:
> |-- scripts
> |-- aaa
> |-- bbb
> | |-- ccc
> |-- ddd
> , where the scripts inside the directory 'scripts' assume this directory
> structure exists and define variables to locate those directories based on
> its location. Something like this:
> Now, to the problem. If I execute a script from its location (i.e. cd to
> scripts and run './<script_name>'), it works fine. However, if I execute
> a script from the project's root directory (i.e. run
> 'scripts/<script_name>'), it does NOT work (for obvious reasons, as
> $PROJ_ROOT is not set correctly anymore).
> Is there a way to define the variable $PROJ_ROOT so that it's always
> correctly set, regardless of where I run the script from (i.e. whether
> it's from its local directory or from somewhere else)??
I'm not sure if I understand the requirements correctly, but when I need
to work from a certain directory in a (bash) shell script I use the
builtin's pushd and popd.
Thank god we have bash on *all* our UNIXen here.
Nate Campi, UNIX Ops WiReD SF, Terra Lycos DNS, (415) 276-8678
More information about the svlug