Date:        Tue, 10 Apr 2018 21:28:01 +0100
    From:        Martijn Dekker <mart...@inlv.org>
    Message-ID:  <6e79f3b1-732e-a7d4-1d07-a04d7a9cf...@inlv.org>

  | But it is. POSIX explicitly specifies quote removal for 'case' patterns:

No, it doesn't.

Read that again, with the emphasis I am adding ...

  | 
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_05
  | | The conditional construct case shall execute the /compound-list/
  | | corresponding to the first one of several /patterns/ (see Pattern
  | | Matching Notation) that is matched by the string resulting from the
  | | tilde expansion, parameter expansion, command substitution,
  | | arithmetic expansion, and quote removal **of the given word**.

That part is talking about the "case $x in" $x is the "given word", that is 
certainly
subject to quote removal.

Lower down, it says ...

        In order from the beginning to the end of the case statement, each 
pattern
        that labels a compound-list shall be subjected to tilde expansion, 
parameter
        expansion, command substitution, and arithmetic expansion, and the 
result
[note: no quote removal]
        of these expansions shall be compared against the expansion of word,
[from the sectin you quoted]
         according to the rules described in Section 2.13

If quote removal were done on patterns, then to match a literal asterisk
we would need something like

        case "$x" in \\*) ...

as the quote removal would leave \* which would then be a quoted asterisk.

Similarly, '*' would be interpreted as just * (the quotes being removed) and
so "match anything" which is  also not what anyone does, or wants.

Not doing quote removal on patterns is correct.

  | I hope you won't change it to ksh93's counterintuitive behaviour. Your 
  | current behaviour is certainly consistent with POSIX (as well as every 
  | other current shell except ksh93).

I have no current plan to change that, this is an area where I believe the
standard needs some work first.   After that, if what the standard says is
different from what we implement, and is also reasonable (and unlikely to
break too much) then I might make changes.

kre

Reply via email to