Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Pattern bug on (a*|)~^(*b)
- X-seq: zsh-workers 51996
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Johan Grande <nahoj@xxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Pattern bug on (a*|)~^(*b)
- Date: Fri, 28 Jul 2023 07:41:06 +0100
- Archived-at: <https://zsh.org/workers/51996>
- In-reply-to: <CAH+w=7YodjiiFGGWn34p5+ajBeBrwzr6=NOHVs4hCa+k_uw=fA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Johan Grande <nahoj@xxxxxxxxx>, zsh-workers@xxxxxxx
- References: <599e3c13-53a5-1823-6d0d-68dd722967d9@crans.org> <CAH+w=7a1CFu9G5Tc3HT=hizPBuaKLbZwg_hRPNTb1G6vWs-2VA@mail.gmail.com> <8c33aa3a-fde5-45ce-8f22-c817c6fa4a9a@crans.org> <CAH+w=7YodjiiFGGWn34p5+ajBeBrwzr6=NOHVs4hCa+k_uw=fA@mail.gmail.com>
2023-07-27 18:02:30 -0700, Bart Schaefer:
> On Tue, Jul 25, 2023 at 11:47 AM Johan Grande <nahoj@xxxxxxxxx> wrote:
> >
> > I don't get it. What are the different patterns tried during this
> > left-to-right evaluation of (|a*)~^(*b) ?
>
> I'm going to invoke my "PWS may be able to explain some more" remark,
> but basically once you cross the "~" it's no longer possible to
> backtrack again; so it tries to match the empty alternative, gets an
> empty result set, excludes ^(*b) from that result set leaving a
> still-empty set, can't go back, and fails because the final result is
> empty. I don't recall all the details but this has something to do
> with X~Y implemented as "exclude Y from the result of X".
I have to say I'm with the OP and don't understand that
explanation either.
It also doesn't seem to tie in with the fact that in globbing
the part after ~ is seemingly done *after* globbing so with
very low precedence, as in ./**/*.txt~*/src/* finding all the
txt files including in src dirs, but the */src/* filtered out
afterwards.
Even if that's "how it works", I struggle to see how it can be
seen as anything but a bug. It's not working as documented, and
I can't really see how we would document it.
See also:
$ [[ ab = a(|a*)~^*b ]]; echo $?
1
$ [[ ab = a(|*b)~^*b ]]; echo $?
1
$ [[ ab = a(*z|*b)~^*b ]]; echo $?
0
Which doesn't seem to tie in with the explanation.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author