[Top][All Lists]

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

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

From: Dietmar Schindler
Subject: Re: Defect in manual section "Conditional Constructs" / case
Date: Wed, 25 Aug 2021 11:50:22 +0200

> sent: 25. August 2021 04:31
> from: "Dale R. Worley"
> Cc: bug-bash@gnu.org
> "Dietmar P. Schindler" <D.P.Schindler@Web.De> writes:
> > Doesn't the example I gave above show that quotes are removed? If they
> > weren't, how could word aa with pattern a""a constitute a match?
> As you say, >a""a< matches as a case-pattern when the case word is
> >aa<. But that's not due to quote removal, because what the case does
> is not testing for string equality. As is done in a number of other
> places in Bash, this is a pattern and it is input to a process of
> pattern matching. See where "pattern" is used in the manual page, and
> the phrase "using the matching rules described under Pattern Matching".

Thanks for the confirmation - indeed it's clearly about Pattern Matching.

> What the Pattern Matching section doesn't seem to say quite directly, is
> that the quoting present in the pattern is considered only in regard to
> that some characters are quoted and some are not. And that certain
> special characters, when unquoted, have special meanings to the pattern
> matching process.
> So when >a""a< is a pattern, it consists of two characters, both
> unquoted-a, and the pattern matches only the string >aa<.
> If >a*a< is a pattern, it consists of three unquoted characters, but
> because the second of them is special, it matches any string that starts
> and ends with >a<. But >a"*"a< consists of three characters, and
> >"a*a"< does too, but because neither of them contains an unquoted
> special character, they both match only >a*a<.

Thanks also for these examples - they similarly to those from Lawrence 
Velázquez show that my suggestion was wrong. I didn't think far enough to apply 
what is documented for an escaping backslash ("is discarded when matching") 
also to quotes.

> They are the same rules that are used for doing pathanme expansion.

Well, as the documentation of filename expansion refers to that of pattern 
matching, it's not too helpful to explain pattern matching this way. ;-)

reply via email to

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