Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Pattern bug on (a*|)~^(*b)
- X-seq: zsh-workers 52009
- From: Johan Grande <nahoj@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Pattern bug on (a*|)~^(*b)
- Date: Tue, 1 Aug 2023 15:19:12 +0200
- Archived-at: <https://zsh.org/workers/52009>
- In-reply-to: <CAH+w=7Z9+VHUc3h_ZULpcnmqReQoQOQ03GuJtTCsBWFKK5Tf5Q@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- 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> <20230728064106.ufcfaqondhn3wge7@chazelas.org> <CAH+w=7Z9+VHUc3h_ZULpcnmqReQoQOQ03GuJtTCsBWFKK5Tf5Q@mail.gmail.com>
Le 29/07/2023 à 03:35, Bart Schaefer a écrit :
On Thu, Jul 27, 2023 at 11:41 PM Stephane Chazelas
<stephane@xxxxxxxxxxxx> wrote:
I have to say I'm with the OP and don't understand that explanation
either.
In the absence of a direct response from PWS, I'll just point you to
his comments in pattern.c, some of which date from before we had a
git repository: [...]
By my reading, zero-length matches may be short-circuited to avoid
pathological behavior.
Thank you for your answers, though the latter is rather obscure to me.
If you can answer, or if PWS reads this:
What globbing should do is one thing, but in the meantime I'm interested
to know what I can safely put on the left-hand side of ~ with the
current implementation. Does this behavior concern any case of
backtracking, or only (...|...) patterns, or, which would be even
better, only (|...) and (...|) patterns?
In my project, I use globbing to find files with tags matching patterns
provided by the user, because I noticed that it's much faster than
anything else I tried, and I use ()~^() and (|) as AND and OR operators.
As an example, here is the pattern generated for files with tags
matching pat1:
*[[](((* |)pat1( *|)))[]]*
which I could easily replace with:
*[[](((* )#pat1( *)#))[]]*
Then this would be the pattern for files with pat1 and pat2 and neither
pat3 nor pat4:
*[[](((* )#pat1( *)#)~^((* )#pat2( *)#))[]]*~*[[](((* )#pat3( *)#|(*
)#pat4( *)#))[]]*
So I'm thinking I could filter for user-provided patterns that contain
'|' and don't put them in the mega-pattern but filter for them
post-globbing. Does that sound like a sound solution to you?
--
Johan
Messages sorted by:
Reverse Date,
Date,
Thread,
Author