On Thu, 2006-07-27 at 16:46 -0600, Dave Smith wrote:
> Andrew Jorgensen wrote:
> > Inside your script you can do (this is bash syntax, so translate to
> > ksh if that's different):
> >
> > DIRNAME=`dirname $0`
> 
> Right on Andrew! I'm a big fan of
> 
>    cd `dirname $0`
> 
> in most of my bash scripts. That way I always know I am executing from 
> the directory containing me.

I have to share a couple of shell scripting rules I follow:

Stuart Rules of Shell Scripting:

1) Always put variables and paths inside of quotes unless you have a
good reason not to. This avoids common bugs during the shell's second
tokenization pass. Most often the bug is a result of filenames
containing spaces.

2) Backticks are evil, use $() instead.

cd "$(dirname \"$0\")"

-- 
Stuart Jansen              e-mail/jabber: [EMAIL PROTECTED]
                           google talk:   [EMAIL PROTECTED]

"However beautiful the strategy, you should occasionally look at 
the results." -- Winston Churchill

Attachment: signature.asc
Description: This is a digitally signed message part

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to