From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6267 invoked from network); 28 Mar 2002 16:00:07 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 28 Mar 2002 16:00:07 -0000 Received: (qmail 12863 invoked by alias); 28 Mar 2002 15:59:55 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16922 Received: (qmail 12842 invoked from network); 28 Mar 2002 15:59:51 -0000 From: "Bart Schaefer" Message-Id: <1020328155914.ZM1111@candle.brasslantern.com> Date: Thu, 28 Mar 2002 15:59:14 +0000 In-Reply-To: Comments: In reply to Wayne Davison "Potential improvement for zmv" (Mar 27, 4:48pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: Zsh Workers Subject: Re: Potential improvement for zmv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 27, 4:48pm, Wayne Davison wrote: } Subject: Potential improvement for zmv } } I implemented a new option for zmv: -W. This works just like -w, with } the additional feature that it automatically transforms wildcards in the } replacement pattern into a sequential series of ${1} .. ${N} vars. } } Here's the patch. Let me know what you think. My only concern is that it should complain if the number of wildcards in the destination is less than the number of wildcards in the source. Else you're likely to lose the rightmost patterns from the source, which are probably the most important (the file name itself). } Since I'm still a novice shell programmer, some of you wizards out } there can undoubtedly improve the shell code I wrote. For instance, } I don't know if it's possible to increment $N inside a global search } and replace (I resorted to using a loop). You can just about do it: integer N=0 x=(x x x x x x) print ${(e)x//x/\$[++N]} but the escaping to wrap each $[++N] in ${...} gets a bit arcane. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net