zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: negative pattern doesn't match empty string in globbing?
Date: Fri, 19 Sep 2014 10:55:02 +0100	[thread overview]
Message-ID: <CAECNH1SHGq5=b71FyGN09ivh2EdTumGG1WP2yJvTriL=jZ8VcQ@mail.gmail.com> (raw)
In-Reply-To: <20140919080426.GA4265@localhost.localdomain>

[-- 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

  reply	other threads:[~2014-09-19  9:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19  8:04 Han Pingtian
2014-09-19  9:55 ` Peter Stephenson [this message]
2014-09-19 10:02 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAECNH1SHGq5=b71FyGN09ivh2EdTumGG1WP2yJvTriL=jZ8VcQ@mail.gmail.com' \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).