From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17117 invoked from network); 24 Apr 2006 15:22:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 24 Apr 2006 15:22:10 -0000 Received: (qmail 2184 invoked from network); 24 Apr 2006 15:22:00 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 24 Apr 2006 15:22:00 -0000 Received: (qmail 24671 invoked by alias); 24 Apr 2006 15:21:51 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10178 Received: (qmail 24661 invoked from network); 24 Apr 2006 15:21:51 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 24 Apr 2006 15:21:51 -0000 Received: (qmail 1056 invoked from network); 24 Apr 2006 15:21:51 -0000 Received: from vms044pub.verizon.net (206.46.252.44) by a.mx.sunsite.dk with SMTP; 24 Apr 2006 15:21:50 -0000 Received: from torch.brasslantern.com ([71.116.76.26]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0IY8007WMG08FS90@vms044.mailsrvcs.net> for zsh-users@sunsite.dk; Mon, 24 Apr 2006 10:21:45 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id k3OFLZQM000392 for ; Mon, 24 Apr 2006 08:21:44 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id k3OFLZKb000391 for zsh-users@sunsite.dk; Mon, 24 Apr 2006 08:21:35 -0700 Date: Mon, 24 Apr 2006 08:21:35 -0700 From: Bart Schaefer Subject: Re: Style question: Can this be written in a more elegant way? In-reply-to: <444C8C0B.6090409@ulpmm.u-strasbg.fr> To: zsh-users@sunsite.dk Message-id: <060424082135.ZM390@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <6F0CB04509C11D46A54232E852E390AC013D956D@MCHP7R6A.ww002.siemens.net> <444C8C0B.6090409@ulpmm.u-strasbg.fr> Comments: In reply to Marc Chantreux "Re: Style question: Can this be written in a more elegant way?" (Apr 24, 10:27am) On Apr 24, 10:27am, Marc Chantreux wrote: } } Here is mine but i'm sure there is faster. } } file=( *(om) ) } (( $file[1] )) && PROG_SUCCESS || PROG_FAIL I think you mean: file=( X*(Nom[1]) ) (( $+file )) && PROG_SUCCESS $file || PROG_FAIL However, that will run PROG_FAIL if PROG_SUCCESS fails, as well as if there are no matching files. I don't think you can avoid if/else. if (( $+file )); then PROG_SUCCESS $file; else PROG_FAIL; fi Note that in the event that there are two or more files with the same time stamp, there's no guarantee which one of them is chosen, and in fact X*(om[1]) and X*(Om[1]) might both choose the same file.