I see this often in the build scripts of projects that use autotools (autoconf, automake). When somebody wants to check the value of a shell variable, they frequently use this idiom:
if test "x$SHELL_VAR" = "xyes"; then
...
What is the advantage to this over simply checking the value like this:
if test $SHELL_VAR = "yes"; then
...
I figure there must be some reason that I see this so often, but I can't figure out what it is.
If you don't do the "x$SHELL_VAR" thing, then if $SHELL_VAR is undefined, you get an error about "=" not being a monadic operator or something like that.