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
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.
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.
Follow-up Comment #6, patch #4916 (project findutils): Robert, could you respond to Andreas's points?
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