2013-12-13 Marcus Poller pointed me to a website about ``Common shell script mistakes''. [0] My opinion is that it contains a lot of good hints, but the advice should not be taken without own judgement. One example is: [ x"$var" = x"find" ] && echo found The use of x"$var" was required in case var is "" or "-hyphen". Thinking about this for a moment should in- dicate that the shell can handle both of these cases unambiguously, and if it doesn't it's a bug. This bug was probably fixed about 20 years ago, so stop pro- pagating this nonsense please! Shell doesn't have the cleanest syntax to start with, so polluting it with stuff like this is horrible. Yes, POSIX defines the interpretation of the test arguments in an unambigous way: [1] 3 arguments: If $2 is a binary primary, perform the binary test of $1 and $3. The first clause for three arguments clarifies the interpretation already. Hence, yes, the interpretation is clear, according to POSIX. But, my experience shows, that it is unclear for the average shell programmer. And (in the notes of the POSIX page): Historical systems have also been unreliable given the common construct: test "$response" = "expected string" One of the following is a more reliable form: test "X$response" = "Xexpected string" test "expected string" = "$response" Note that the second form assumes that expected string could not be confused with any unary primary. If ex- pected string starts with '-', '(', '!', or even '=', the first form should be used instead. My opinion is, that these forms test x"$foo" = x"bar" test "X$foo" = "Xbar" are simple, clear, and reliable for every programmer and on every system, thus use them. [0] http://www.pixelbeat.org/programming/shell_script_mistakes.html [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html http://marmaro.de/lue/ markus schnalke