bug-bash
[Top][All Lists]
Advanced

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

Re: bash "extglob" needs to upgrade at least like zsh "kshglob"


From: Chet Ramey
Subject: Re: bash "extglob" needs to upgrade at least like zsh "kshglob"
Date: Thu, 17 Nov 2022 16:29:32 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 11/17/22 6:05 AM, Koichi Murase wrote:

Thank you for the patch.  I applied it locally and tried it.  I attach
a test script that I used: [bracket-slash.sh].  Now I switched to a
loadable builtin that directly calls strmatch instead of hacking
GLOBIGNORE.  Here are the results:

   ---Tests for a slash in bracket expressions---
   #1: pat=ab[/]ef          str=ab[/]ef          yes/yes
   #2: pat=ab[/]ef          str=ab/ef            no/no
   #3: pat=ab[c/d]ef        str=ab[c/d]ef        yes/yes
   #4: pat=ab[c/d]ef        str=abcef            yes/no
   #5: pat=ab[.-/]ef        str=ab[.-/]ef        no/yes
   #6: pat=ab[.-/]ef        str=ab.ef            yes/no
   #7: pat=ab[[=/=]]ef      str=ab[[=/=]]ef      yes/yes
   #8: pat=ab[[=/=]]ef      str=ab/ef            no/no
   #9: pat=ab[[=c=]/]ef     str=ab[=/]ef         yes/yes
   #10: pat=ab[[=c=]/]ef     str=abcef            yes/no
   #11: pat=ab[[:alpha:]/]ef str=ab[:/]ef         yes/yes
   #12: pat=ab[[:alpha:]/]ef str=abxef            yes/no
   #13: pat=ab[/[abc]]ef     str=ab[/c]ef         yes/yes
   #14: pat=ab[/[abc]]ef     str=abc]ef           no/no
   #15: pat=ab[c[=/=]]ef     str=ab[c[=/=]]ef     yes/yes
   #16: pat=ab[c[=/=]]ef     str=abc[=/=]ef       no/no
   #17: pat=ab[c[=/=]]ef     str=abcef            yes/no
   ---Tests for incomplete bracket expressions---
   #18: pat=ab[c             str=ab[c             yes/yes
   #19: pat=ab[c             str=abc              no/no
   #20: pat=ab[c[=d=         str=ab[c[=d=         yes/yes
   #21: pat=ab[c[=d=         str=abc              no/no
   #22: pat=ab[c[.d          str=ab[c[.d          yes/yes
   #23: pat=ab[c[.d          str=abc              no/no
   #24: pat=ab[c[:alpha:     str=ab[c[:alpha:     yes/yes
   #25: pat=ab[c[:alpha:     str=abc              no/no
   #26: pat=ab[c-            str=ab[c-            no/yes
   #27: pat=ab[c-            str=abc              no/no
   #28: pat=ab[c\            str=ab[c\            no/yes
   #29: pat=ab[c\            str=abc              no/no
   #30: pat=ab[[\            str=ab[[\            no/yes
   #31: pat=ab[[\            str=ab[              no/no

"yes" and "no" on the left of / in the fourth column are the results
after applying the patch you provided. "yes" and "no" on the right of
/ are the results that *I* expect (see below paragraphs).

The new treatment seems to only handle a slash that directly appears
as an independent character in bracket expressions (cases
#1,#2,#13,#14), but if I literally read the standard you quoted, I
feel we should also handle other slashes (#3..#6,#9..#12,#15..#17).

Yes, I was undecided at the time whether character classes and equivalence
classes should have the same treatment or fall back to invalid classes. I
think your interpretation there is the right one.

The same is true for ranges. If either the first character or the second
character in the range is a slash it should cause the bracket to be matched
literally.

Incidentally, I made an additional change so that an incomplete range
expression causes the bracket to be matched literally.

Thanks for the discussion. I attached an updated version of the patch I
sent yesterday. I wasn't quite as aggressive as you with macros.

Chet

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

Attachment: bracket-slash.patch
Description: Text document


reply via email to

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