From: Bart Schaefer <schaefer@brasslantern.com>
To: Johan Grande <nahoj@crans.org>
Cc: zsh-workers@zsh.org
Subject: Re: Pattern bug on (a*|)~^(*b)
Date: Tue, 25 Jul 2023 11:35:38 -0700 [thread overview]
Message-ID: <CAH+w=7a1CFu9G5Tc3HT=hizPBuaKLbZwg_hRPNTb1G6vWs-2VA@mail.gmail.com> (raw)
In-Reply-To: <599e3c13-53a5-1823-6d0d-68dd722967d9@crans.org>
On Tue, Jul 25, 2023 at 6:19 AM Johan Grande <nahoj@crans.org> wrote:
>
> In zsh 5.8.1 (x86_64-ubuntu-linux-gnu) with extended_glob,
>
> [[ "ab" = (|a*)~^(*b) ]]
>
> incorrectly (unless I'm mistaken) returns 1.
This is not precisely a bug, it's expected behavior. Alternation with
(x|y) tries the patterns in left-to-right order and has lower
precedence than p~q (despite the parens). The upshot is that
(|a*)~^(*b) matches like (|)~^(*b) whereas (a*|)~^(*b) is like
(a*)~^(*b) and the final bit of the puzzle is that the double negative
in ~^(b*) cannot match the empty result from (|).
The same thing happens with globbing, touch a file named "ab" and then
try those patterns for filename generation. PWS may be able to
explain some more about the precedence of (x|y) vs. (p~q).
To resolve this, you have to put the p~q inside the x|y, like [[ "ab"
= (|a*~^(*b)) ]]
next prev parent reply other threads:[~2023-07-25 18:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-25 13:19 Johan Grande
2023-07-25 18:35 ` Bart Schaefer [this message]
2023-07-25 18:47 ` Johan Grande
2023-07-28 1:02 ` Bart Schaefer
2023-07-28 6:41 ` Stephane Chazelas
2023-07-29 1:35 ` Bart Schaefer
2023-08-01 13:19 ` Johan Grande
2023-08-01 13:30 ` Peter Stephenson
2023-08-01 13:46 ` Johan Grande
2023-08-02 8:31 ` Johan Grande
2023-08-02 9:37 ` Peter Stephenson
2023-07-31 11:36 ` Peter Stephenson
2023-07-31 15:21 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7a1CFu9G5Tc3HT=hizPBuaKLbZwg_hRPNTb1G6vWs-2VA@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=nahoj@crans.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).