From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3179 invoked by alias); 27 Jul 2011 14:11:25 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16145 Received: (qmail 12394 invoked from network); 27 Jul 2011 14:11:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.220.171 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=BrkzZMETpFuCzj1RsY6+pFQypVBXcPkypyDrNbWUMoE=; b=dkY1CP3bSk1b3kXIAHmvbjn43r58h7SeoEzbCges4hBXvslirTP7NCZsZIdTs5I1D2 0rweaVBdm6YY66YQ+40uPwF3WTC1+jfbO4lEhe3HJ/LhpAT7ImThFb0IiobrbmG9pNas mHMmfCsYPRyMXrfD1w9g63DMn9b6HfiB7W1k8= MIME-Version: 1.0 In-Reply-To: <1311774830.29469.2156456149@webmail.messagingengine.com> References: <1311774830.29469.2156456149@webmail.messagingengine.com> Date: Wed, 27 Jul 2011 16:11:14 +0200 Message-ID: Subject: Re: Why does this extended glob pattern fail? From: Mikael Magnusson To: Ronald Fischer Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 27 July 2011 15:53, Ronald Fischer 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