ssm-scala icon indicating copy to clipboard operation
ssm-scala copied to clipboard

xargs: invalid option -- 'o' when -x

Open shtukas opened this issue 7 years ago • 2 comments

ssm ssh -x -t security-hq,security,PROD --newest --profile security
xargs: invalid option -- 'o'
Usage: xargs [-0prtx] [--interactive] [--null] [-d|--delimiter=delim]
       [-E eof-str] [-e[eof-str]]  [--eof[=eof-str]]
       [-L max-lines] [-l[max-lines]] [--max-lines[=max-lines]]
       [-I replace-str] [-i[replace-str]] [--replace[=replace-str]]
       [-n max-args] [--max-args=max-args]
       [-s max-chars] [--max-chars=max-chars]
       [-P max-procs]  [--max-procs=max-procs] [--show-limits]
       [--verbose] [--exit] [--no-run-if-empty] [--arg-file=file]
       [--version] [--help] [command [initial-arguments]]

Report bugs to <[email protected]>.

See https://www.gnu.org/software/findutils/manual/html_node/find_html/xargs-options.html versus https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/xargs.1.html

shtukas avatar May 08 '18 17:05 shtukas

The following establishes the session automatically, but doesn't connect connect up stdin (i.e. isn't interactive).

... | xargs -r0 sh -c "$@"

Some progress...

adamnfish avatar May 08 '18 17:05 adamnfish

Got it.

... | xargs -r sh -c 'exec "$@" < /dev/tty' SSM

So we can detect OSX / vs a GNU OS in the wrapper script and use the appropriate xargs invocation in each case.

It's too late to fix now, but if no one beats me to it I'll PR this tomorrow.

adamnfish avatar May 08 '18 17:05 adamnfish