From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28609 invoked by alias); 27 Jul 2011 14:40:40 -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: 16146 Received: (qmail 11876 invoked from network); 27 Jul 2011 14:40:34 -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=-1.0 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at seebyte.com does not designate permitted sender hosts) X-Virus-Scanned: Debian amavisd-new at mail.seebyte.com Date: Wed, 27 Jul 2011 15:32:11 +0100 From: Stephane Chazelas To: Ronald Fischer Cc: zsh-users@zsh.org Subject: Re: Why does this extended glob pattern fail? Message-ID: Mail-Followup-To: Ronald Fischer , zsh-users@zsh.org References: <1311774830.29469.2156456149@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1311774830.29469.2156456149@webmail.messagingengine.com> User-Agent: Mutt/1.5.16 (2007-09-19) 2011-07-27 15:53:50 +0200, Ronald Fischer: > 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? [...] Yes, {...} is expanded early, so it becomes cp ^$from/*.log ^$from/*.png $dest You could use: cp ^$from/*.{log,png}(N) $dest or files=(^$from/*.{log,png}(N)) (($#files)) && cp $files $dest or better, use globbing alternate operator rather than brace expansion: cp ^$from/*.(log|png) $dest -- Stephane