zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: how to?
Date: Sat, 24 Aug 2002 03:47:00 +0000	[thread overview]
Message-ID: <1020824034700.ZM22554@candle.brasslantern.com> (raw)
In-Reply-To: <20020823202218.A13113@globnix.org>

On Aug 23,  8:22pm, Phil Pennock wrote:
} 
} On 2002-08-23 at 15:59 +0000, Bart Schaefer wrote:
} > c=(*.c) o=(*.o(N)) eval 'ls ${${c:#(${~${(j:|:)${o:r}}}).c}:?done}'
} 
} (for reference, mine was:
}  print -l -- *.c(e:[[ ! -f '${REPLY%.c}.o' ]]:)
} )
} 
} One thing that I try to avoid is building up the first list in an array.
} I keep hitting machine limits on argv, so I tend to be cautious about
} _anything_ which builds lists

Your caution is somewhat misplaced.  The glob isn't enumerated anywhere,
except internally to zsh when processing the assignment; machine limits on
argv will only come into play when an external command is involved (e.g.,
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").

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.

The size of the environment also has an effect -- you might try exporting
as little as possible, if you frequently hit argv limits.

} Out of curiosity: the (e::) thing builds the parse tree beforehand and
} is pretty efficient, isn't it?  I've never had cause to try it on huge
} sets of data ...

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).

} 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?

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.

-- 
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   


  parent reply	other threads:[~2002-08-24  3:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-23 13:35 Scott Lipcon
2002-08-23 15:14 ` Phil Pennock
2002-08-23 15:59 ` Bart Schaefer
     [not found]   ` <20020823202218.A13113@globnix.org>
2002-08-24  3:47     ` Bart Schaefer [this message]
2002-08-24 21:56       ` Phil Pennock
2002-08-25  5:27         ` Bart Schaefer
2002-08-25 22:47           ` Phil Pennock
2002-08-27 10:34 ` Roman Neuhauser
2002-08-27 17:20   ` Phil Pennock
2002-08-27 18:00     ` Roman Neuhauser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1020824034700.ZM22554@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).