* negative pattern doesn't match empty string in globbing?
@ 2014-09-19 8:04 Han Pingtian
2014-09-19 9:55 ` Peter Stephenson
2014-09-19 10:02 ` Peter Stephenson
0 siblings, 2 replies; 3+ messages in thread
From: Han Pingtian @ 2014-09-19 8:04 UTC (permalink / raw)
To: zsh-users
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* negative pattern doesn't match empty string in globbing?
2014-09-19 8:04 negative pattern doesn't match empty string in globbing? Han Pingtian
@ 2014-09-19 9:55 ` Peter Stephenson
2014-09-19 10:02 ` Peter Stephenson
1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2014-09-19 9:55 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 1142 bytes --]
On Friday, 19 September 2014, Han Pingtian <hanpt@linux.vnet.ibm.com
<javascript:_e(%7B%7D,'cvml','hanpt@linux.vnet.ibm.com');>> 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 my phone at a
bus stop, or at least trying. (I'm now half way to Truro and
on the third browser...)
Negative patterns are confusing, I've discovered over the years.
The way to think of them is "match anything but..."
In other words, first match something, and only then decide
what to exclude.
In this case, the initial "match anything" matches files in the directory
you've reached. Obviously there is no empty file. So the overall match fails
at that point.
Phew... time to hit send...
pws
^ permalink raw reply [flat|nested] 3+ messages in thread
* negative pattern doesn't match empty string in globbing?
2014-09-19 8:04 negative pattern doesn't match empty string in globbing? Han Pingtian
2014-09-19 9:55 ` Peter Stephenson
@ 2014-09-19 10:02 ` Peter Stephenson
1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2014-09-19 10:02 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 1142 bytes --]
On Friday, 19 September 2014, Han Pingtian <hanpt@linux.vnet.ibm.com
<javascript:_e(%7B%7D,'cvml','hanpt@linux.vnet.ibm.com');>> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-19 10:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-19 8:04 negative pattern doesn't match empty string in globbing? Han Pingtian
2014-09-19 9:55 ` Peter Stephenson
2014-09-19 10:02 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).