zsh-workers
 help / color / mirror / code / Atom feed
From: Dima Kogan <zsh@dima.secretsauce.net>
Cc: zsh-workers@zsh.org
Subject: Re: Possible bug in zargs
Date: Tue, 30 Oct 2012 10:53:47 -0700	[thread overview]
Message-ID: <20121030105347.58405603@shorty.local> (raw)
In-Reply-To: <121030090909.ZM7599@torch.brasslantern.com>

> On Tue, 30 Oct 2012 09:09:09 -0700
> Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Oct 30, 12:05am, Dima Kogan wrote:
> }
> } Attached is a patch that fixes this. There was some misbehaving logic
> } in the script. I don't understand why that logic was ever necessary.
> } Does anybody know why the value of $n was connected to the value of $c
> } at all?
> 
> Sorry, meant to reply to this thread earlier but I had an unusually busy
> weekend.  Short answer:  The previous behavior was the intended behavior
> and I'm going to recommend against accepting this patch.
> 
> $n represents the maximum number of arguments that may be passed to the
> called command.  NOT the maximum number of arguments that may be taken
> from the input list and added to the other arguments of the command, but
> the maximum that may be passed to the command, period.
> 
> $c is the number of arguments of the command that appear outside of the
> input list, that is, the number of arguments that trail the end of the
> whole zargs construct.  In your example:
> 
> } > dima@shorty:/tmp$ zargs -n1 -- * -- ls -l
> } > zargs: argument list too long
> 
> You've said that "ls" should be passed at most one argument (-n1).  That 
> one argument is "-l".  Therefore there is no room to pass any of the
> arguments from the input list (expansion of "*") without passing too
> many arguments, so you get the error.
> 
> This may seem silly your example above, but it could be very important
> if for example you're using a larger value of -n with some sort of
> $(command) substitution generating the command for zargs to execute.
> 
> What you actually want in your example is this:
> 
>     zargs -l1 -- * -- ls -l
> 
> The manual page explains this:
> 
>      The options -i, -I, -l, -L, and -n differ slightly from their
>      usage in xargs.  There are no input lines for zargs to count, so
>      -l and -L count through the INPUT list, and -n counts the number
>      of arguments passed to each execution of COMMAND, _including_ any
>      ARG list.  Also, any time -i or -I is used, each INPUT is
>      processed separately as if by `-L 1'.
> 

Thanks, Bart. I indeed missed that part of the doc. Sorry for the false alarm.

dima


      reply	other threads:[~2012-10-30 18:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-27 22:34 Dima Kogan
2012-10-30  7:05 ` Dima Kogan
2012-10-30 16:09   ` Bart Schaefer
2012-10-30 17:53     ` Dima Kogan [this message]

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=20121030105347.58405603@shorty.local \
    --to=zsh@dima.secretsauce.net \
    --cc=zsh-workers@zsh.org \
    /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).