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

Re: PATCH: zsh 3.x: <..> ranges in globbing

On Mon, 12 Jan 1998, Peter Stephenson wrote:

> You should probably note that <100->0foo won't match 1000foo, since
> the 1000 gets swallowed up before the shell even knows it's going
> to have to match another digit next. This is a much more difficult
> problem requiring backtracking.  I could make a special case so that
> simple things like this work, but expressions like <100->(0|bar)foo would
> require much more fiddling.  (Of course, <100-999>0foo works now.)

I am not sure, that it is right thing. The <m-n> can (always?) be
rewritten using plain extended regular expression. In particular, <100->
is the same as


given file foo with

at my system I get

egrep '([1-9][0-9][0-9]|[1-9][0-9]{3,})0foo' foo
=> 1000foo

egrep '([1-9][0-9][0-9]|[1-9][0-9]{3,})foo' foo
=> 100foo

X/OPEN (and presumably POSIX and Unix 95) also require BRE and ERE to
match the longest possible string - in case of 1000foo the longest
possible is the whole word :-)

Actually, what about replacing "ad hoc" code in ZSH by direct translation
into normal regexp? It will probably be faster (who knows) and will give
ZSH full power to support i18n - wich is currently not (portably)
possible. I think, that <m-n> globbing is the only non-trivial part - all
others are pretty sraightforward.

Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@xxxxxx

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