zsh-workers
 help / color / mirror / code / Atom feed
From: Johan Grande <nahoj@crans.org>
To: Bart Schaefer <schaefer@brasslantern.com>, zsh-workers@zsh.org
Subject: Re: Pattern bug on (a*|)~^(*b)
Date: Tue, 1 Aug 2023 15:19:12 +0200	[thread overview]
Message-ID: <16673694-5299-cf1c-8553-c3d703d942d0@crans.org> (raw)
In-Reply-To: <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@chazelas.org> 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


  reply	other threads:[~2023-08-01 13:20 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
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 [this message]
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=16673694-5299-cf1c-8553-c3d703d942d0@crans.org \
    --to=nahoj@crans.org \
    --cc=schaefer@brasslantern.com \
    --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).