[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: |
Tue, 22 Nov 2022 15:24:21 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 |
On 11/20/22 7:50 AM, Koichi Murase wrote:
This difference is caused because the slash after the backslash is
only checked after a matching character is found
(lib/glob/sm_loop.c:703). The same check should be applied also
before a matching character is found (lib/glob/sm_loop.c:573). I
attach a patch for this [r0037.brackmatch6.remaining-slash.patch].
I agree with this; it was an inadvertent omission.
There is another related inconsistency. I just modified my new
extglob engine to follow Bash's choice described above, but then the
behavior became different from that of the actual implementation of
Bash of the current devel.
"If a pattern ends with an unescaped <backslash>, it is unspecified whether
the pattern does not match anything or the pattern is treated as invalid."
[...]
b. If this is the behavior for the unescaped backslashes outside the
bracket expressions, which is intensionally different from those in
the bracket expressions, would it be possible to change the
treatment of the unescaped backslashes inside the bracket
expression the same as that of outside so the bracket `[' matches
literally (as expected in cases #28..#31 of my previous reply [1])?
The attached [r0037.brackmatch7.unescaped-backslash-option-b.patch]
is the corresponding patch.
I have changed my mind, and I agree with this. I think the latest draft
of the POSIX standard requires it unambiguously:
"A <left-square-bracket> that does not introduce a valid bracket expression
shall match the character itself."
and while it does not say so explicitly (the description defers to the
regular expression description, which describes valid bracket expressions
as having a closing bracket), I think it's reasonable to conclude that an
incomplete bracket expression without a `]' is invalid, this text from the
regular expression description aside:
"An expression containing a '[' that is unescaped and is not part of a
bracket expression produces undefined results."
since the text in "Patterns Matching a Single Character" supersedes it.
I attached the latest patch against bash-5.2.9.
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/
bracket-slash.patch
Description: Text document
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Chet Ramey, 2022/11/03
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Koichi Murase, 2022/11/14
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Chet Ramey, 2022/11/16
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Koichi Murase, 2022/11/17
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Chet Ramey, 2022/11/17
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Koichi Murase, 2022/11/18
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Koichi Murase, 2022/11/20
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob",
Chet Ramey <=
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Koichi Murase, 2022/11/28
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Koichi Murase, 2022/11/28
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Chet Ramey, 2022/11/17
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Koichi Murase, 2022/11/18
- Re: bash "extglob" needs to upgrade at least like zsh "kshglob", Koichi Murase, 2022/11/17