[Wolves] Shell Script "text variable"

David Goodwin dg at clocksoft.com
Mon Jan 16 21:36:30 GMT 2006

> > if [ "x$someVariable" == "xSomething" ]; then
> >      # do something here.
> > fi
> Why do you have the x at the beginning of the strings
> in the test?  Are you trying to provide a default
> value in case $someVariable isn't set (in which case
> you dont need it as long as you quote the strings so
> it defaults to "" if its null) or is this some arcane
> hacker magic?

It's mostly a bad (unnecessary) habit from when I knew far 
less, to get around dealing with unset variables.

Alternatively you can do a "if [ -z $foo ] ; then echo 'foo is set'; fi"

David Goodwin
w: http://www.clocksoft.co.uk 
e: david.goodwin at clocksoft.com
t: 0121 313 3850

More information about the Wolves mailing list