Zsh Mailing List Archive
Messages sorted by:
Re: question about zargs
- X-seq: zsh-users 17365
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-user <zsh-users@xxxxxxx>
- Subject: Re: question about zargs
- Date: Wed, 31 Oct 2012 14:25:46 +0000
- In-reply-to: <20121031134007.GA9731@localhost.localdomain>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <20121031134007.GA9731@localhost.localdomain>
On Wed, 31 Oct 2012 21:40:07 +0800
Han Pingtian <hanpt@xxxxxxxxxxxxxxxxxx> wrote:
> I just learnt that there is a function 'zargs' which just like
> 'xargs'. So why we need the 'zargs' as we have 'xargs' already?
> As a example, this works just fine with 'xargs':
> % print -N **/* | xargs -n1 -0 ls
It works, but with more processes. zargs allows you to have things
(though not ls) running completely in the shell. In that case, you
aren't sensitive to the size of the argument list passed to an external
> But this one will cause "(eval):2: fork failed: cannot allocate
> memory" error on my laptop:
> % zargs **/* -- ls
ls is run as an external process, so the argument list is limited.
zargs doesn't have a builtin system-dependent limit to the number it'll
pass in one go, unlike xargs, as far as I can see, so needs to be told
how to limit it.
Hmm... in principle, you can do:
zargs -n2 **/* -- ls
so that it executes ls and one additional argument each time. This is
equivalent to the -n1 you gave to xargs.
However, with a lot of iles this is running incredibly slowly for me and
after a few dozen files have been processed I hit:
279: mem.c:1180: MEM: allocation error at sbrk, size 589824.
zargs:279: fatal error: out of memory
(Luckily this is in a subshell.)
It looks like this is hitting some pathology in memory management to do
with the argument array (which is being shifted at that line).
Messages sorted by: