Search This Blog

Wednesday, July 28, 2010

Safest way of comparing values using Variable.

Method 1:
if [ "x$HAVE_CIFS" = "xyes" ]; then
...
fi

Method 2:
if [ "$HAVE_CIFS" = "yes" ]; then
...
fi

in above 2 methods method one is safest as it deals with versions of "test" that don't deal with empty strings correctly.

Now onwards i will try to use the safest way whenever is possible.

reference
http://www.linuxquestions.org/questions/showthread.php?p=4048568&posted=1#post4048568

More of Robust scripting article can be found in following blog entry.
http://learnlinuxwithrohan.blogspot.com/2010/08/robust-scripting.html

No comments:

Post a Comment