I just ran a simple one-liner[1] to find the average filepath
length on my system (absolute paths) and that came up with a value
~90 characters. Assume this is out by a factor of two, we still
have potentially 5000 more arguments that we can put into the buffer.
Surely one might run xargs(1) on something that is not a filename.
We just choose to accomodate the common use-case as much as possible.
[1] find / 2>/dev/null | awk '{print length($0)}' \
| awk '{a+=$1}END{print "average filepath length: ",a/NR}'
We cannot rely on ungetc() pushing back more than 1 character
reliably on all systems, so just note if we have leftover input and
process it in the next run.
We still have a few error codes to do, namely when the process
is killed or stopped by a signal or when one or more invocations
of the command returned a nonzero exit status.