How to pass argument to script which is input to bash
I believe what you are looking for is the -s
option. With -s
, you can pass arguments to the script.
As a dummy example to illustrate this:
$ echo 'echo 1=$1' | bash -s -- Print
1=Print
Here, you can see that the script provided on stdin is given the positional parameter Print
. Your script takes a -u UUID
argument and that can be accommodated also:
$ echo 'echo arguments=$*' | bash -s -- -u UUID print
arguments=-u UUID print
So, in your case:
curl -fsSL http://git.io/vvZMn | bash -s -- print
Or,
curl -fsSL http://git.io/vvZMn | bash -s -- -u UUID print
As Stephen Harris pointed out, downloading a script and executing it, sight unseen, is a security concern.
If your system has /dev/stdin
, you can use
$ echo 'echo 1=$1' | bash /dev/stdin print
1=print
Do not do this:
$ echo 'echo 1=$1' | bash /dev/stdin -- print
1=--
If you want to use --
, do this:
$ echo 'echo 1=$1' | bash -- /dev/stdin print
1=print