If you're using a shell that does simple substitution and the SHELL_VAR
variable does not exist (or is blank), then you need to watch out for the edge cases. The following translations will happen:
if test $SHELL_VAR = yes; then --> if test = yes; then
if test x$SHELL_VAR = xyes; then --> if test x = xyes; then
The first of these will generate an error since the fist argument to test
has gone missing. The second does not have that problem.
Your case translates as follows:
if test "x$SHELL_VAR" = "xyes"; then --> if test "x" = "xyes"; then
The x
, at least for POSIX-compliant shells, is actually redundant since the quotes ensue that both an empty argument and one containing spaces are interpreted as a single object.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…