From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4138 invoked from network); 24 Aug 2002 21:56:33 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 24 Aug 2002 21:56:33 -0000 Received: (qmail 28307 invoked by alias); 24 Aug 2002 21:56:12 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5282 Received: (qmail 28287 invoked from network); 24 Aug 2002 21:56:11 -0000 Date: Sat, 24 Aug 2002 23:56:10 +0200 From: Phil Pennock To: zsh-users@sunsite.dk Subject: Re: how to? Message-ID: <20020824235610.A94@globnix.org> Mail-Followup-To: zsh-users@sunsite.dk References: <20020823133510.2B8EC5B5@mercea.net> <1020823155954.ZM21819@candle.brasslantern.com> <20020823202218.A13113@globnix.org> <1020824034700.ZM22554@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="Dxnq1zWXvFF0Q93v" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1020824034700.ZM22554@candle.brasslantern.com>; from schaefer@brasslantern.com on Sat, Aug 24, 2002 at 03:47:00AM +0000 X-Disclaimer: Any views expressed in this message, where not explicitly attributed otherwise, are mine and mine alone. Such views do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2002-08-24 at 03:47 +0000, Bart Schaefer wrote: > On Aug 23, 8:22pm, Phil Pennock wrote: Most of my mail was curiosity. I'm not too sure of most of this, hence I didn't CC the list but instead made it a private reply. Sorry for any offense caused -- I see that I didn't tone my wording well. > there might be a problem with the "ls ${c}" in my solution, but the spec > said "do an ls" not "do a print -l", and your solution passes exactly the > same number of arguments to "print -l --" as mine passes to "ls"). True, but it was "ls -1" so I added another optimisation, to avoid the extra stat()s. > In other words, you might have reason to be cautious about anything that > *expands* a list, but just building one (i.e., array assignment) should > not be an issue unless you're hitting stacksize or memoryuse limits. Noted. I still try to avoid risking hitting stacksize limits, though. Influence of years ago doing Comp Sci work on an Amiga, when others used Unix. I tend to try to explicitly free memory that I allocate. I try to avoid techniques which chew a lot of stack or other RAM. I might do something quick and dirty, but will try to fix it before it goes into a script. > The size of the environment also has an effect -- you might try exporting > as little as possible, if you frequently hit argv limits. Ah, it's usually not envp subtracting from argv, but more a case of having my mind tracking a few things, finding no tags file for /usr/src/sys/ on a BSD system and trying a grep for something across all the kernel source, with **/*.[chyl] -- the failure leads to my blinking, grumbling, writing a find/xargs version and then trying to remember what I was looking at before. Also dealing with mailboxes which have been forged as the envelope sender in spam. 60,000 mails, two files each. I wrote tools to handle it more efficiently in Perl, since the regular easy shell stuff kept barfing. > I timed your solution and mine using repeated runs on about 400 files > (after changing mine to also use the "print" builtin) and they're almost > exactly the same. Yours uses a little more system time, mine a little > more user time (file tests vs. string manipulation, I suppose). *nods* Thanks. Sorry, I was asking more if you knew of the top of your head; I should have said so, to avoid you running tests which I was too lazy to try. > } Which leads to a question: how much hassle is it to have a glob modifier > } be able to duplicate the Simple Command which is calling it? >=20 > A glob modifier, just about impossible. A precommand modifier or option, > perhaps. The problem is, by the time the E2BIG error comes back from > execve(2), it's too late to do much except croak -- so zsh would need a > heuristic to predict whether/how to split up the arguments, so it could > be done sooner. Are there sufficient hooks to allow this to be done as a module? I have enough interest in this to actually go back to looking at zsh internals and writing a module. sysconf(_SC_ARG_MAX) should return the space available. More overhead in tracking the sizes of all strings explicitly and summing them before a command, but then that can be restricted to just the case when a glob is used, so it wouldn't normally slow things. But, uhm, not for a month or so. --=20 "Markets can remain irrational longer than you can remain solvent" -- John Maynard Keynes --Dxnq1zWXvFF0Q93v Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (OpenBSD) iD8DBQE9aAD5fDS04Uzk9lURAugeAKCtM0+sQ3uMw66t8wn6Od59XYuSfQCg2gjJ FcgiH35AOpKztzBUtg+QjA0= =tERJ -----END PGP SIGNATURE----- --Dxnq1zWXvFF0Q93v--