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: Dale R. Worley
Subject: Re: Defect in manual section "Conditional Constructs" / case
Date: Tue, 24 Aug 2021 22:31:22 -0400

"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".

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<. 

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

Dale



reply via email to

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