On Tue, Apr 10, 2018 at 01:41:25PM +0100, Martijn Dekker wrote: > Re: https://github.com/att/ast/issues/71
> Consider this test script: > (set -o posix) 2>/dev/null && set -o posix > emulate sh 2>/dev/null # for zsh > for var in 'a-c' '!a'; do > case b in > ( ["$var"] ) echo 'quirk' ;; > ( [$var] ) echo 'no quirk' ;; > esac > done > Most shells output 'no quirk' for both values of 'var', but AT&T ksh93 > outputs 'quirk' for both, as does zsh 5.2 and earlier (zsh-as-sh changed > to match the majority in 5.3). Now one of the current ksh93 lead > developers says this does not look like a bug. > Does POSIX specify anything, either way, regarding the effect of shell > quoting within glob bracket patterns? I can't find any relevant text > under "2.13 Pattern Matching Notation" or anything it references, so > clarification would be appreciated. The first paragraph of 2.13.1 Patterns Matching a Single Character contains some confusing or contradictory text about backslashes; this text was amended for http://austingroupbugs.net/view.php?id=806 but was confusing or contradictory even before that change. The change was made for fnmatch() and perhaps the part about backslashes in the first paragraph was actually meant to handled in the last paragraph in the part that explicitly says it is only about contexts such as fnmatch() where shell quote removal is not performed. The rest of 2.13.1 discusses "quoting" of characters in various locations. I think it is reasonable to assume that shell quoting is meant. Only the effect of quoting '!', '-' and ']' in a bracket expression is not specified (but the effect of quoting '^' is: it makes the '^' a literal part of the set). I prefer "no quirk" twice as output but it is indeed not fully specified. -- Jilles Tjoelker