#353281 xargs -J (FreeBSD compatibility)

Package:
findutils
Source:
findutils
Description:
utilities for finding files--find, xargs
Submitter:
Robert Millan
Date:
2018-12-23 12:03:02 UTC
Severity:
wishlist
#353281#5
Date:
2006-02-17 10:37:31 UTC
From:
To:
Please could you add -J as an alias for -I ? This is for compatibility with FreeBSD.

I sent it to upstream BTS:

https://savannah.gnu.org/patch/index.php?func=detailitem&item_id=4916

#353281#10
Date:
2007-04-21 16:47:26 UTC
From:
To:
Follow-up Comment #5, patch #4916 (project findutils):

Hello,
I am not sure about the patch. (file#9590) Afaict it is supposed to make
xargs act the same way for -J as for -I with a single difference: Replace
only the first instance of replace-string.
----------------------
*prompt*$ printf 'bar fasel\n' | ./xargs -I % echo x % 1 % 2 %
x bar fasel 1 bar fasel 2 bar fasel
*prompt*$ printf 'bar fasel\n' | ./xargs -J % echo x % 1 % 2 %
x bar fasel 1 % 2 %
----------------------

However afaiui the FreeBSD manpage there are at least two other significant
differences. "-I" changes xargs' behavior in multiple aspects:
#1 split only on line ends instead of also on space:
---------------------
ametzler@argenau:/tmp$ touch 'blah fasel'
ametzler@argenau:/tmp$ printf 'blah fasel\n' | xargs  -I % ls %
blah fasel
ametzler@argenau:/tmp$ printf 'blah fasel\n' | xargs  ls
ls: blah: No such file or directory
ls: fasel: No such file or directory
---------------------
#2 execute utility *once* for every line of input instead of making the
commandline longer.

Afaiu the manpage "-J" is not supposed to make either of these two changes to
xargs' default behavior, i.e. this should be the resulting behavior:
ametzler@argenau:/tmp$ printf 'blah fasel\nnonexist\n' | xargs -J % ls %
ls: blah: No such file or directory
ls: fasel: No such file or directory
ls: nonexist: No such file or directory
ametzler@argenau:/tmp$ printf 'blah fasel\nnonexist\n' | xargs -J % echo x %
x blah fasel nonexist

The above mentioned difference #1 between FreeBSD xargs and patched GNU-find
causes different results, #2 only degraded performance.

On top of that the patch seems to be buggy with respect to multiline input.
Only the first line of input is actually passed on:
ametzler@argenau:/tmp$ printf 'blah fasel\nnonexist\n' |
/tmp/findutils-4.2.27/xargs/xargs -J % echo x %
x blah fasel
x %

Sorry for the delay in following up.

cu andreas
PS: I have not got access to a FreeBSD system to actually test its behavior,
my only source of input is the online manpage.

#353281#13
Date:
2007-04-21 16:47:26 UTC
From:
To:
Follow-up Comment #5, patch #4916 (project findutils):

Hello,
I am not sure about the patch. (file#9590) Afaict it is supposed to make
xargs act the same way for -J as for -I with a single difference: Replace
only the first instance of replace-string.
----------------------
*prompt*$ printf 'bar fasel\n' | ./xargs -I % echo x % 1 % 2 %
x bar fasel 1 bar fasel 2 bar fasel
*prompt*$ printf 'bar fasel\n' | ./xargs -J % echo x % 1 % 2 %
x bar fasel 1 % 2 %
----------------------

However afaiui the FreeBSD manpage there are at least two other significant
differences. "-I" changes xargs' behavior in multiple aspects:
#1 split only on line ends instead of also on space:
---------------------
ametzler@argenau:/tmp$ touch 'blah fasel'
ametzler@argenau:/tmp$ printf 'blah fasel\n' | xargs  -I % ls %
blah fasel
ametzler@argenau:/tmp$ printf 'blah fasel\n' | xargs  ls
ls: blah: No such file or directory
ls: fasel: No such file or directory
---------------------
#2 execute utility *once* for every line of input instead of making the
commandline longer.

Afaiu the manpage "-J" is not supposed to make either of these two changes to
xargs' default behavior, i.e. this should be the resulting behavior:
ametzler@argenau:/tmp$ printf 'blah fasel\nnonexist\n' | xargs -J % ls %
ls: blah: No such file or directory
ls: fasel: No such file or directory
ls: nonexist: No such file or directory
ametzler@argenau:/tmp$ printf 'blah fasel\nnonexist\n' | xargs -J % echo x %
x blah fasel nonexist

The above mentioned difference #1 between FreeBSD xargs and patched GNU-find
causes different results, #2 only degraded performance.

On top of that the patch seems to be buggy with respect to multiline input.
Only the first line of input is actually passed on:
ametzler@argenau:/tmp$ printf 'blah fasel\nnonexist\n' |
/tmp/findutils-4.2.27/xargs/xargs -J % echo x %
x blah fasel
x %

Sorry for the delay in following up.

cu andreas
PS: I have not got access to a FreeBSD system to actually test its behavior,
my only source of input is the online manpage.

#353281#16
Date:
2007-04-29 00:53:13 UTC
From:
To:
Follow-up Comment #6, patch #4916 (project findutils):

Robert, could you respond to Andreas's points?

#353281#19
Date:
2011-06-25 22:13:26 UTC
From:
To:
Follow-up Comment #7, patch #4916 (project findutils):

Sorry for the delay. Please consider the attachment, I looked at Andrea's
points and implemented a patch that follows them.


(file #23561)
    _______________________________________________________

Additional Item Attachment:

File name: xargs_J.diff                   Size:2 KB