bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Defect in manual section "Conditional Constructs" / case


From: Chet Ramey
Subject: Re: Defect in manual section "Conditional Constructs" / case
Date: Wed, 25 Aug 2021 10:25:04 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 8/24/21 1:47 AM, Dietmar_Schindler@web.de wrote:

> In the section 
> https://www.gnu.org/software/bash/manual/bash.html#Conditional-Constructs in 
> the description of the "case" command there is no mention (as far as I can 
> see, it doesn't follow from the documented expansions etc.) that a _pattern_ 
> undergoes quote removal, but it does [see e. g. case aa in a""a) echo match;; 
> esac]. (One might think it does self-evidently in the process of "Shell 
> Expansions" performed on the command line, but this expansion series is not 
> performed on the case command's _word_ and patterns - they for example don't 
> undergo brace expansion -; for _word_, it is explicitly said: "The _word_ 
> undergoes tilde expansion, parameter expansion, command substitution, 
> arithmetic expansion, and quote removal …"; for _pattern_: "Each _pattern_ 
> undergoes tilde expansion, parameter expansion, command substitution, and 
> arithmetic expansion." - quote removal is missing.)
> 
> To rectify it, I suggest to change and simplify these sentences from
> 
>       The _word_ undergoes tilde expansion, parameter expansion, command 
> substitution, arithmetic expansion, and quote removal (see Shell Parameter 
> Expansion) before matching is attempted. Each _pattern_ undergoes tilde 
> expansion, parameter expansion, command substitution, and arithmetic 
> expansion.
> 
> to
> 
>       The _word_ and each _pattern_ undergo tilde expansion, parameter 
> expansion, command substitution, arithmetic expansion, and quote removal (see 
> Shell Parameter Expansion) before matching is attempted.

Thanks for the report. This was changed in the devel branch back in May as
the result of

https://lists.gnu.org/archive/html/bug-bash/2021-05/msg00030.html

There was also a discussion on the POSIX mailing list about the wording.

It's tricky in the sense that quote removal, according to the strict shell
definition, is performed -- the literal quote characters are removed and
don't appear in the expanded pattern. The complication is that the shell
and pattern matcher have to arrange for the quoted characters to be
marked appropriately for the pattern matcher itself, so quoted special
characters lose their special meaning and match themselves. That has to
happen internally, using whatever API or function the pattern matcher
offers.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]