simple (and stupid) shell scripting question

Christian Weisgerber naddy at
Mon Feb 15 14:48:32 UTC 2010

Nerius Landys <nlandys at> wrote:

> #!/bin/sh
> DIRNAME="`dirname \"$0\"`"
> cd "$DIRNAME"
> SCRIPTDIR="`pwd`"
> What if I got rid of extra double quotes?  Like this:
> DIRNAME=`dirname \"$0\"`
> cd "$DIRNAME"

That is perfectly fine.  Word-splitting and filename expansion are
not performed for variable assignments.  Also immune is the expression
after "case", so this is always fine:
  case $FOO in ...
Christian "naddy" Weisgerber                          naddy at

More information about the freebsd-questions mailing list