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

Re: [BUG] Glob handling is brittle



On Tue, 2018-11-27 at 21:14 +0900, Jun T wrote:
> > 2018/11/26 14:38, Martijn Dekker <martijn@xxxxxxxx> wrote:
> > The script below reliably makes zsh hang.
> (snip)
> > 
> > case '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' in
> > ( *\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\\
> > *\\*\\*\\*\\*\\*\\*\\*\\*\\*\\* )
> > 	echo ok ;;
> > esac
> zsh is not hanging; it is just very slow.

Yes, you can see that by gradually increasing the length of the
pattern.  Depending on the machine, it starts to get really slow after
about half a dozen or so \\* groups.

> I don't know whether this can be 'fixed' easily.

There's something a bit similar that does improve the case of excluded
matches, ~ and ^ --- where you hit pathological cases quite quickly, and
which aren't so commonly used in patterns.  That's not nice.  It's
almost certainly not a good idea to do it that way here, as * is very
widely used indeed.  I can't offhand think of a good way of fixing up
pathological cases without having a much more noticeable effect on more
typical cases.  But I don't think offhand thinking is what's required
here.

Really, this is at the point where you need an algorithm expert rather
than a bunch of hackers.

pws



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