Re: strange behavour with combining -i with -n 1 for xargs

Andreas Metzler <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
On 2021-10-22 "Koopal, Andre via Bug reports for the GNU find utilities" <[email protected]> wrote:
> I tried the following which didn't work as expected:

> % echo a b c | gxargs -n 1 -i echo before {} after
> before a b c after
[...]
> This seems like a bug to me, can you investigate?

Hello,

 -I replace-str
        Replace occurrences of replace-str in the initial-arguments with
        names read from standard input.  Also, unquoted  blanks  do  not
        terminate  input  items;  instead  the  separator is the newline
        character.  Implies -x and -L 1.
 -L max-lines
        Use at most max-lines nonblank input  lines  per  command  line.
        Trailing blanks cause an input line to be logically continued on
        the next input line.  Implies -x.
 -n max-args, --max-args=max-args
        Use  at  most  max-args  arguments per command line.  Fewer than
        max-args arguments will be used if the size (see the -s  option)
        is  exceeded, unless the -x option is given, in which case xargs
        will exit.

These options cannot be used together, since -I implies -L 1 and specifying
both -L and -n does not make sense.

Current xargs (4.8.0) will throw a warning on this input:
--------------
argenau:~> echo a b c | xargs -n 1 -i echo before {} after
xargs: warning: options --max-args and --replace/-I/-i are mutually
exclusive, ignoring previous --max-args value before a b c after
-------------

cu Andreas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.