On 4/6/13 4:48 AM, Dan Douglas wrote:
I couldn't find anything obvious in POSIX that implies which interpretation is
correct. Assuming it's unspecified.
Bash (4.2.45) uniquely does interpret such escapes for [[, which makes me
think this test should say "no":
x=\\x; if [[ x == $x ]]; then echo yes; else echo no; fi
bash: yes
ksh: no
mksh: no
zsh: no
However, ksh93 (AJM 93v- 2013-03-17) is unique in that it flips the result
depending on "[[ ]]" or "case..esac" (bug?), but otherwise it looks like a
fairly random spread:
x=\\x; case x in $x) echo yes;; *) echo no; esac
These two cases should not be different. They undergo the same expansions,
except that the conditional command adds quote removal, which doesn't
matter in this case. In both cases, you ask the pattern matching code
whether or not the string `x' matches the pattern `\x'.
You invoke the same pattern matching code on the same patterns, why would
you not get the same answer?