Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash < <(curl -s https://rvm.io/install/rvm): What Does it Do? [duplicate]

Possible Duplicate:
What does it mean “bash < <( curl rvm.io/releases/rvm-install-head )”

I'm working to install Ruby on Rails on Mac OS X lion and came across several tutorials which called on this line:

bash < <(curl -s https://rvm.io/install/rvm)

I don't know what the bash < < bit is for.

What does this line do?

Thanks

like image 535
Tyler DeWitt Avatar asked Jan 18 '23 16:01

Tyler DeWitt


1 Answers

The first < redirects the file on the right side to the stdin of the command on the left side.

The <(...) syntax runs the command specified, saving its output to a named pipe (a special kind of file that outputs whatever is written into it without saving it to the disk) and replaces the whole <(...) with the name of the file. This is called process substitution (you can look it up in man bash) and it is used whenever a file would be needed but you want to use the output of a command instead.

As for curl, it is a command which downloads the URL given to it as argument, and outputs it to the screen (stdout).

In summary, what the command you gave does is:

  1. Runs bash, giving it as input the contents of a temporary named pipe.
  2. Downloads the URL https://rvm.io/install/rvm, which is a bash script, and saves it to the temporary named pipe given as input to bash.

This effectively runs the script at the URL with bash.

like image 56
drrlvn Avatar answered Jan 30 '23 21:01

drrlvn