I have the following command:
xargs -d '\n' -n 8 bash -c 'phpcs_element PSR2 "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"' -- >&2 2>/dev/null
If I run this command into Linux it will work, if I try to run in into Mac OSX will not because the OSX xargs doesn't know about xargs -d (delimiter).
xargs: illegal option -- d
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements] [-S replsize]]
[-J replstr] [-L number] [-n number [-x]] [-P maxprocs]
[-s size] [utility [argument ...]]
Have anyone found a workaround for this issue?
Xargs Version: src/usr.bin/xargs/strnsubst.c,v 1.7 2004/10/18 15:40:47
Thanks in advice.
Just use -0
instead (making the NUL character the delimiter), and convert your newlines to NULs (which are what you ought to be using to separate items in a list of file names in the first place: the NUL, not the newline, is the only character that cannot exist in a filesystem path).
tr '\n' '\0' |
xargs -0 -n 8 bash -c 'phpcs_element PSR2 "${@:1:8}"' -- >&2 2>/dev/null