From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15203 invoked from network); 6 Jan 2000 14:52:04 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 6 Jan 2000 14:52:04 -0000 Received: (qmail 22389 invoked by alias); 6 Jan 2000 14:50:17 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2839 Received: (qmail 22352 invoked from network); 6 Jan 2000 14:50:15 -0000 Date: Fri, 7 Jan 2000 01:54:33 +1100 From: Andre Pang To: Oliver Kiddle Cc: zsh-users@sunsite.auc.dk Subject: Re: Prompt expansion, multi-job for Message-ID: <20000107015433.B333@bozar.ihug.com.au> Reply-To: Andre Pang Mail-Followup-To: Oliver Kiddle , zsh-users@sunsite.auc.dk References: <20000106194432.A488@bozar.ihug.com.au> <3874847D.A2ED4AE3@u.genie.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <3874847D.A2ED4AE3@u.genie.co.uk>; from opk@u.genie.co.uk on Thu, Jan 06, 2000 at 12:03:09PM +0000 Sender: andrep@vjolnir.org On Thu, Jan 06, 2000 at 12:03:09PM +0000, Oliver Kiddle wrote: > Andre Pang wrote: > > > 2) Is there any way to emulate make's -jn option in the for command? > > This would be *really* useful for SMP systems. Currently, doing something > > like "for i in ***/***.wav; do l3enc $i; done" doesn't take advantage of > > multiple CPUs (on a Linux system, at least); hacking the for command to > > accept a 'make -j'-like parameter (eg: for -j2 i in *; do l3enc $i; done) > > would allow us lucky ones who have SMP systems to do many things similar to > > the above without going mad and writing silly Makefiles simply so we can > > utilise make -j. If someone's written a function to do this already (Bart? > > ;) it'd be *very* cool. > > If I'm not mistaken, you should be able to do this by running l3enc as a > background process, i.e. for i in *.wav; do l3enc $i& done. I haven't > got an SMP system available to me to test but I'd assume that it would > allocate different l3enc processes to different processors. Putting the Yes, you're right there. I've done this a few times when I've had < 15 jobs to run, but today, I did a 'for i in ***/***.wav; do shorten $i; done', and I have easily >200 .wavs which I wanted to compress. Running 200 background processes isn't my idea of fun :). > a maximum of 4 l3encs at once. This would be a bit messy to implement in > Zsh (compared to something like Ada) but can be done. Which brings me back to my original question - if someone has a function to do this already, I'll be most happy. I'm just not sure whether it's possible to make a function which can emulate the behaviour of the for command perfectly, because it's treated as a complex command and not as a function. I'm thinking that the only way to implement this gracefully would be to either (a) change the syntax of the new function, thus having a for command with a different syntax - annoying[1], or (b) modify the zsh source to deal with it, which I would love to do, but I lack the skill for. Suggestions, guys? [1] Perhaps the closest you'd get is ``jfor -2 i in * do 'l3enc -q $i; echo done $i' done'' -- note the lack of semicolons and the single quotes around the commands to run. Even then, the syntax is different from normal for. Syntax change == bad. -- : Andre Pang - Purruna Pty Ltd - ph# 0411.882299 : : #ozone - http://www.vjolnir.org/ozone/ :