Sat 21 Apr 2007 04:47:24 PM UTC, comment #5:
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.
|