From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27935 invoked from network); 18 May 2009 09:57:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 18 May 2009 09:57:24 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 29371 invoked from network); 18 May 2009 09:57:10 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 May 2009 09:57:10 -0000 Received: (qmail 2724 invoked by alias); 18 May 2009 09:56:25 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14134 Received: (qmail 2652 invoked from network); 18 May 2009 09:56:22 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 18 May 2009 09:56:22 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 4C3338027106 for ; Mon, 18 May 2009 11:56:17 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly15g.srv.mailcontrol.com (MailControl) with ESMTP id n4I9sNFp006401 for ; Mon, 18 May 2009 10:56:01 +0100 Received: from news01 ([10.99.50.25]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Mon, 18 May 2009 10:55:44 +0100 Date: Mon, 18 May 2009 10:55:39 +0100 From: Peter Stephenson To: zsh-users@sunsite.dk Subject: Re: [[ -f file* ]] Message-ID: <20090518105539.33d058e2@news01> In-Reply-To: <17393e3e0905180236v424b14d5ua9d364501662c75a@mail.gmail.com> References: <20090518091455.83279.qmail@smasher.org> <17393e3e0905180236v424b14d5ua9d364501662c75a@mail.gmail.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 May 2009 09:55:44.0714 (UTC) FILETIME=[CFC182A0:01C9D79E] X-Scanned-By: MailControl A-06-00-00 (www.mailcontrol.com) on 10.71.0.125 X-Virus-Scanned: ClamAV 0.94.2/9366/Mon May 18 08:02:23 2009 on bifrost X-Virus-Status: Clean On Mon, 18 May 2009 05:36:18 -0400 Matt Wozniski wrote: > On Mon, May 18, 2009 at 5:14 AM, Atom Smasher wrote: > > if i want to test for the presence of one or more files matching a certain > > pattern, it seems non-trivial to do it with the normal "test" or conditional > > expressions. > ... > > is there a better way? > > Well, off the top of my head, I can think of > > [ -n "$(print -- test*(N))" ] > > but even that seems inelegant; I'm sure someone can chime in with > something better. has_matches() { (( $# > 0 )) } if has_matches test*(N); then # some matches else # no matches fi You need to remember the (N). There are ways around that. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070