From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23340 invoked from network); 11 Mar 2005 04:49:13 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Mar 2005 04:49:13 -0000 Received: (qmail 11790 invoked from network); 11 Mar 2005 04:49:07 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Mar 2005 04:49:07 -0000 Received: (qmail 15041 invoked by alias); 11 Mar 2005 04:48:58 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8578 Received: (qmail 15029 invoked from network); 11 Mar 2005 04:48:57 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 11 Mar 2005 04:48:57 -0000 Received: (qmail 10713 invoked from network); 11 Mar 2005 04:48:53 -0000 Received: from vms046pub.verizon.net (206.46.252.46) by a.mx.sunsite.dk with SMTP; 11 Mar 2005 04:48:50 -0000 Received: from candle.brasslantern.com ([4.11.1.68]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0ID60051U81CIST1@vms046.mailsrvcs.net> for zsh-users@sunsite.dk; Thu, 10 Mar 2005 22:48:49 -0600 (CST) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j2B4mlaT009338 for ; Thu, 10 Mar 2005 20:48:47 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j2B4mls9009337 for zsh-users@sunsite.dk; Thu, 10 Mar 2005 20:48:47 -0800 Date: Fri, 11 Mar 2005 04:48:46 +0000 From: Bart Schaefer Subject: Re: Ex-bash script for optimisation In-reply-to: <62u0315opl6kubat89fmdng5dg4m4370o0@4ax.com> In-reply-to: <42308ED6.6030007@Sun.COM> To: zsh-users@sunsite.dk Message-id: <1050311044847.ZM9336@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <62u0315opl6kubat89fmdng5dg4m4370o0@4ax.com> <42308ED6.6030007@Sun.COM> Comments: In reply to zzapper "Ex-bash script for optimisation" (Mar 10, 4:43pm) Comments: In reply to Peter Miller "Re: Ex-bash script for optimisation" (Mar 10, 1:15pm) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 Comments on script style: None of the variables is declared (with "declare" or "local") so this is probably not suitable for use as an autoloaded shell function. "filebad" is set but not used, and there's no reason to use "let" syntax if you're not doing arithmetic (in the assignment of 1 to filebad). On Mar 10, 4:43pm, zzapper wrote: } Subject: Ex-bash script for optimisation } } Q1) Is there a better way to generate the array filelst Sure. You don't need the loop, just do a glob with an extended pattern. #--- snip --- setopt local_options extended_glob null_glob filelst=( *$1*~*.(aux|toc|dvi|aux|exe|obj|zip|pdf|mdb|xls|bak|swp|log|jpg|gif|tiff|jpeg|bmp) ) #--- snip --- If you want to allow $1 to be a pattern rather than a fixed string, you need *${~1}* instead. If you want to allow multiple arguments to the script, you need *${^*}* or for multiple patterns *${^~*}* In the event that you really need to loop, zsh 4.2+ supports array append with the syntax: filelst+=($x) } Q2) the line "for x in *$1*" fails is no match, how can i "catch" this Peter Miller's *$1*(N) suggestion is equivalent to the "null_glob" setting in my example above.