seeking to upgrade my bash magic. help decipher this command: bash -s stable
ok so i'm working through a tutorial to get rvm installed on my mac. the bash command to get rvm via curl is
curl -L https://get.rvm.io | bash -s stable
i understand the first half's curl command at location rvm.io, and that the result is piped to the subsequent bash command, but i'm not sure what that command is doing. My questions:
-s : im always confused about how to refer to these. what type of thing is this: a command line argument? a switch? something else?
-s : what is it doing? i have googled for about half an hour but not sure how to refer to it makes it difficult.
stable : what is this?
tl;dr : help me decipher the command bash -s stable
to those answering this post, i aspire to one day be as bash literate as you. until then, opstards such as myself thank you for the help!
The -s
thing is called an option. In your case, it means that bash
will be executed with the first positional parameter set. If you want to play with that:
$ bash -s let us set some positional parameters just for fun
$ # doh? nothing seemed to happen
$ # In fact here we're in a new instance of bash with the parameters set. Look:
$ echo "$3"
set
$ echo "$5"
positional
$ # Get it?
$ printf "%s\n" "$@"
let
us
set
some
positional
parameters
just
for
fun
$ # Amazing!
$ # Let's get out of here!
$ exit
$ # (back to previous bash session)
$
In your case, the script downloaded via curl is sent to bash
(so it will be executed) and will have the first positional parameter set to stable
.
If ever you're stuck with options you don't know what they do: man bash
and then type /-s
this will more or less get you to where the -s
option is described. Or if you want to know what the -u
option does for sed
: man sed
and then type /-u
.
Hope this helps!