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

negative pattern doesn't match empty string in globbing?



On Friday, 19 September 2014, Han Pingtian <hanpt@xxxxxxxxxxxxxxxxxx
<javascript:_e(%7B%7D,'cvml','hanpt@xxxxxxxxxxxxxxxxxx');>> wrote:
> Hello,
>
> I just notice that negative pattern like this doesn't work:
>
>     localhost% setopt extendedglob
>     localhost% print /usr/**/bin/zsh
>     /usr/bin/zsh /usr/local/bin/zsh

>     localhost% print /usr/^local/bin/zsh
>     zsh: no matches found: /usr/^local/bin/zsh
>     localhost% ls /usr//bin/zsh
>     /usr//bin/zsh
>     localhost%
>
> I think if "^local" can match with empty string, then this should work.
> But looks like it doesn't.

Please excuse formatting,  I'm writing this on a phone on a bus
and have encountered a catalogue of problems...

Negative pattern matches are confusing.

Think about them as "match anything but..."

In other words,  first match something, then decide what to exclude.

In this case the matches are all the files in the directory (and not the
empty string).  So the overall match fails when you try to exclude
everything.

(The keyboard's completion keeps offering 'Scotland'.  Must turn off
trending phrases.)

Hope for a mobile cell soon...

pws


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