shlib.sh: provide xargs wrapper to compensate for broken behavior
commite666896b70d518934690fe2c6ad4dd75f73a0c65
authorKyle J. McKay <mackyle@gmail.com>
Fri, 24 Apr 2015 22:34:44 +0000 (24 15:34 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Fri, 24 Apr 2015 22:34:44 +0000 (24 15:34 -0700)
treee7b5a478b4c3104ee85915d955b4a4af07f85588
parent0d6987a84acf4465195c74012771f09f0d3f473b
shlib.sh: provide xargs wrapper to compensate for broken behavior

On some platforms running the following:

  xargs </dev/null echo broken

outputs "broken" instead of nothing.  So if you're feeding the command
a list of file names to operate on as output by find, it gets run with
no arguments at all even if nothing is found.

This is very bad.

Supply an xargs() wrapper function in shlib.sh that automatically
provides the correct option on broken platforms that need it in
order to suppress this broken behavior and correctly not run the
utility at all if there are no incoming arguments to xargs.

Note that conveniently we can use xargs itself to diagnose this
problem by running:

  : | xargs echo -r

Which will output '-r' on platforms that need it to fix the
broken behavior.  We just do this once and save the result
in the var_xargs_r variable.

And now that we have the wrapper in place, we remove the kludge
from the xargs line in install.sh since it's no longer necessary.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
install.sh
shlib.sh