From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11891 invoked by alias); 4 Mar 2012 18:48:55 -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: 16830 Received: (qmail 13895 invoked from network); 4 Mar 2012 18:48:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.214.171 as permitted sender) Received-SPF: pass (google.com: domain of mikachu@gmail.com designates 10.60.4.202 as permitted sender) client-ip=10.60.4.202; Authentication-Results: mr.google.com; spf=pass (google.com: domain of mikachu@gmail.com designates 10.60.4.202 as permitted sender) smtp.mail=mikachu@gmail.com; dkim=pass header.i=mikachu@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+FoN8UnOG5qqVnqRk3fokotXc+yVcddFgPN7xyllQUw=; b=zCNtPpiNp0xp0edYHzfJBInWihNQWe0isl+VH+tvfCFpQHi2ZQZ4xKkcamhUguqaTa CSn6fQiVxjCTXnDeKhZicphMABtbytKZdwdswfWfR62u3cgo6/3NZcfaPch6oHPctkoB Y+zxx/a81t2AhOpTUSgHy/Z5OZ/pkOqigHALRackQedwthQ+rrUV9R+i+Nx6GXe+UHbN Lt3IY7C2Lm4VW1sUSK0uG139+IHej3T9nfecqVaeYz01A6dm4gUqp2/SL8Ikl8eWc88d r/dTT9JwftrduOPKYXQ9mJvoj+wCMo6G9RS1qoEab9vXqLuumi+a5as9eFqAED++16Ij 99fA== MIME-Version: 1.0 In-Reply-To: <120304103757.ZM24588@torch.brasslantern.com> References: <20120304143102.GE18164@solfire> <120304103757.ZM24588@torch.brasslantern.com> Date: Sun, 4 Mar 2012 19:48:37 +0100 Message-ID: Subject: Re: if the file is not found the files is not found is the file not found From: Mikael Magnusson To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: text/plain; charset=UTF-8 On 4 March 2012 19:37, Bart Schaefer wrote: > On Mar 4, 3:31pm, meino.cramer@gmx.de wrote: > } > } [ -f ${f}-[0-9]*.mp2 ]] && rm -f ${f}-[0-9]*.mp2 > > This won't work even if the files do exist, because you can't apply > a single "-f" test to the multiple files that result from the glob. > > Also you've used "[" on the left but "]]" on the right, which is > mostly nonsense. If you instead used [[ on the left then the glob > would not be expanded and the test would again fail. > > On Mar 4, 3:37pm, Mikael Magnusson wrote: > } > } If you setopt extendedglob you can append (#qN) to the pattern > > You don't even need extendedglob -- you just need bare_glob_qual, which > is on by default unless you're in sh/ksh emulation modes: > > rm -f ${f}-[0-9]*.mp2(N) Ah, I've had them both on since forever and knew extendedglob wasn't on by default, so I assumed bareglobquals was also off. > I'm sure the archives of zsh-users hold many different answers to the > question, "Given a file pattern, how do I test whether at least one > matching file exists?" Unfortunately, there's really no way to do so > in a single operation unless you set the no_nomatch option. [[ ]] > does not perform globbing, and the test operators such as [ -f ] are > defined to return TRUE rather than FALSE on a *missing* file name > operand, so null_glob is not sufficient. Here's one more for the collection, if () { (( $# )) } arglblargh*(N[1]); then echo yes; else echo no; fi But this needs the 'new' anon functions with arguments support. -- Mikael Magnusson