Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Pattern bug on (a*|)~^(*b)



On 01/08/2023 14:19 Johan Grande <nahoj@xxxxxxxxx> wrote:
> 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?

Yes, I think that would be OK.  The only case I definitely know of where
you'd hit the problem would be branches using that specific syntax.
I'm not entirely sure if you'd get issues with approximation, which is
even more complicated, but so long as there are no (#a...)'s in your
patterns that's not a problem.

If you can guarantee that the first branch is a longer match than the
second, you'll also get a away with it.  So (a*|) will work, because
the first branch must be at least 1 character, and the second can't
have any.  Obviously, that's harder to check for automatically, though,
but you could do a limited check, say, that any | was followed by a
right parenthesis.

pws




Messages sorted by: Reverse Date, Date, Thread, Author