Re: Comparing two strings (one may be a null)
Cyrus Kriticos <cyrus.kriticos@googlemail.com> writes:
> if [ "$foo" = "bar" ] ; then
Another approach is to use
if [ X$foo = Xbar ] ; then
That's in case $foo has the value of "=", which would case the line to
be evaluated as
if [ = = bar ]
which can generate a syntax error.
But if foo has a space, that fails as well.
Which leads to combining the two:
if [ "X$foo" = Xbar ] ; then
Cheers....
|