Attempt 1
xargs -I '{}' -0 -n 1 myprogram --arg '{}' --other-options
But that does not preserve zero bytes. Also the program may run multiple times. But instead of failing in case of zero byte creeping into stdin, it runs program multiple times.
Attempt 2
myprogram --arg "`cat`" --other-options
But that does not preserve trailing whitespace.
Attempt 3
bash -c 'read -r -d "" INPUT ; myprogram --arg "$INPUT" --other-options'
Seems to mess with terminal, also fails to preserve trailing whitespace.
How do I do it properly, reliably, readably, compatibly?
xargs
instead of one... – Vi. Jan 14 '16 at 23:24