[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:32:33 -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 8:14 PM, Lawrence Velázquez wrote:
> On Tue, Aug 24, 2021, at 4:44 PM, Dietmar P. Schindler wrote:
>> 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?
>
> The quotes are handled by the matching process itself, *not* as
> part of the usual shell expansions. Otherwise these patterns would
> be equivalent, but they're not.
>
> % cat /tmp/foo.sh
> case $1 in
> 'a?a') echo one ;;
> a?a) echo two ;;
> esac
> % bash /tmp/foo.sh 'a?a'
> one
> % bash /tmp/foo.sh aaa
> two
The literal quote characters are removed, and the characters between the
quotes are appropriately quoted for the pattern matcher, so they're forced
to match themselves. This happens AIBM.
--
``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/