zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Ronald Fischer <ynnor@mm.st>
Cc: zsh-users@zsh.org
Subject: Re: Why does this extended glob pattern fail?
Date: Wed, 27 Jul 2011 16:11:14 +0200	[thread overview]
Message-ID: <CAHYJk3RyorbpBmqeB-XHgZpNSjdGk_+6C--zf=waY2RCL++bBA@mail.gmail.com> (raw)
In-Reply-To: <1311774830.29469.2156456149@webmail.messagingengine.com>

On 27 July 2011 15:53, Ronald Fischer <ynnor@mm.st> wrote:
> In my zsh script, I want to copy all files from a directory, except
> files ending in .log and .png. This is my code:
>
> ....
> setopt extendedglob # makes ^ work in glob pattern
> cp ^$from/*.{log,png} $dest
> ....
>
> However, there are cases when $from has neither .log nor .png files; but
> it DOES contain other files. In this case I get the error message
>
>   no matches found: ^/home/...../*.log
>
> I think this has to do with the timing of when interpretation of {....}
> and when globbing is done. Why exactly do I get the error message, and
> how do I code this correctly?

The pattern you've written will never do what you want, because you're
using {,} instead of (|), which means it expands before globbing, to
the two patterns ^*.log ^*.png, the first one will happily match png
files while the second one matches log files. This also causes the
error when one of those don't produce any matches but the other does.
What you want is ^*.(log|png) which should match the correct things.

-- 
Mikael Magnusson


  reply	other threads:[~2011-07-27 14:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 13:53 Ronald Fischer
2011-07-27 14:11 ` Mikael Magnusson [this message]
2011-07-27 14:32 ` Stephane Chazelas
2011-08-01 10:20   ` Ronald Fischer
2011-08-01 11:04     ` Peter Stephenson
2011-08-01 13:24     ` ZyX

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='CAHYJk3RyorbpBmqeB-XHgZpNSjdGk_+6C--zf=waY2RCL++bBA@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=ynnor@mm.st \
    --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).