From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29305 invoked by alias); 31 Oct 2012 16:30:47 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17366 Received: (qmail 15478 invoked from network); 31 Oct 2012 16:30:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <121031093018.ZM11752@torch.brasslantern.com> Date: Wed, 31 Oct 2012 09:30:17 -0700 In-reply-to: <20121031142546.529e1709@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: question about zargs" (Oct 31, 2:25pm) References: <20121031134007.GA9731@localhost.localdomain> <20121031142546.529e1709@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-user Subject: Re: question about zargs MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Preface for Han Pingtian: If the command you're going to run is external to the shell, then I recommend you use xargs. However, in some cases it may be desirable to get xargs-like behavior when passing arguments to a shell function or builtin, which is why there is zargs. On Oct 31, 2:25pm, Peter Stephenson wrote: } Subject: Re: question about zargs } } 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. Well, yes and no. zargs -n2 is not "equivalent to" xargs -n1 in the general case. In the previous thread about this, it was pointed out that zargs -n2 **/* -- ls -l is equivalent to zlargs -l1 **/* -- ls -l But the only reason you need -n2 is because of the "-l" that is already trailing the "ls" command. If there are no trailing arguments (that is, the command is a name only) then -n1 and -l1 are equivalent. } 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 Hmm, "a few dozen" isn't nearly enough to trigger this for me, though if I run it on a sufficiently large set of files I can watch the memory usage of the shell grow steadily throughout. And yes, it can be slow. If I try zlargs -l1 **/* -- print > /dev/null the memory use jumps much faster, probably because no forking is involved. -- Barton E. Schaefer