[Top][All Lists]

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

Re: Question about case statement in Bash docs

From: Chet Ramey
Subject: Re: Question about case statement in Bash docs
Date: Mon, 10 May 2021 10:28:22 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

On 5/10/21 10:23 AM, Andreas Schwab wrote:
On Mai 10 2021, Greg Wooledge wrote:

On Mon, May 10, 2021 at 09:12:33PM +1000, AlvinSeville7cf wrote:
    case $x in
        "test") echo Y

    Pattern is quoted but no quote removal is performed according to docs.

Quote removal is essential, because of the way the empty string
is matched:

case $foo in
   "") echo "foo is empty";;

So, it may be a documentation omission, or maybe it's mentioned in some
other paragraph, but either way quote removal definitely happens here.

IIUC there is no need for quote removal, because quoting is part of the
rules for pattern matching.

That assumes that the quoted portions are translated into something that
is quoted acceptably for the pattern matcher. Double quotes don't have
any special meaning in patterns.

Either way, quote removal happens, the double quotes are removed, and
the characters between the double quotes are treated specially.

``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]