The regular case with linefeeds, xargs
calls printf
and something is printed:
>>printf "foo\n" | xargs -r printf "->%s\n"
->foo
>>
With an empty input instead, -r
makes xargs
not call the command at all:
>>printf "\n" | xargs -r printf "->%s\n"
>>
Using nulls instead of line feeds, everything is the same if there is an input to xargs
:
>>printf "foo\0" | xargs -r -0 printf "->%s\n"
->foo
>>
But if there is no input, something is printed anyway:
>>printf "\0" | xargs -r -0 printf "->%s\n"
->
>>
So, either
I'm missing something (what?)
There is some good reason to ignore
-r
when used with-0
(but which)?There is a bug in my
xargs
(findutils 4.6.0.225-235f) but it's hard to decide:- I find the same behavior in two other instances (a 4.7.0-git on Ubuntu 16.04 and another 4.6.0 on Windows),
- I can't believe this kind of thing could slip thru regression tests.
- On the other hand this question implies that it could have worked in the past
So, what is the true expected behavior of xargs
?