Date:        Tue, 10 Apr 2018 21:28:01 +0100
    From:        Martijn Dekker <>
    Message-ID:  <>

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

No, it doesn't.

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

  | | 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 
subject to quote removal.

Lower down, it says ...

        In order from the beginning to the end of the case statement, each 
        that labels a compound-list shall be subjected to tilde expansion, 
        expansion, command substitution, and arithmetic expansion, and the 
[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.


Reply via email to