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

Re: How do I find shortest match?




On Thursday, May 17, 2012 at 3:05 PM, Peter Stephenson wrote:

> There's a really nasty trick that doesn't require them to correspond to files, which you'll hate. I think you can combine it into a single expression, but it's bad enough in two.
> 
> local min
> min=(${${(o)${MATCHES//?/\?}}[1]})
> print -l ${MATCHES:#^${~min}}
> 
> I'm sure it's completely obvious what this is doing. It's been posted before. 
I have the memory and attention span of a tsetse fly, so I'll take your word for it, although I myself have no idea what this is doing. I've long accepted the fact that zsh is smarter than I am, and only hope to make the best use of it whenever possible :-) 

TjL

ps - Thanks for the reply and solutions. 







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