[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Interpretation of escapes in expansions in pattern matching contexts
From: |
Dan Douglas |
Subject: |
Interpretation of escapes in expansions in pattern matching contexts |
Date: |
Sat, 06 Apr 2013 03:48:55 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; ) |
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
bash: yes
ksh: yes
mksh: no
posh: no
zsh: no
dash: yes
bb: no
jsh: no
18:42:44 jilles: ormaaj, I'm not sure if that's actually a bug
18:43:15 ormaaj: dunno. Bash seems unique in that respect
18:43:23 jilles: you're asking the shell to check if the string x matches the
pattern stored in the variable x
19:32:51 jilles: freebsd sh and kmk_ash say no, dash says yes
19:33:40 jilles: Bourne shell says no
--
Dan Douglas
- Interpretation of escapes in expansions in pattern matching contexts,
Dan Douglas <=