Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could someone please explain this bash command?

Tags:

bash

terminal

From the website for RVM:

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

What does that first less-than symbol do? What about the <(? I know this is a stupid question, but I'd love to understand this.

like image 486
ClosureCowboy Avatar asked Mar 08 '11 03:03

ClosureCowboy


People also ask

How do you explain bash?

Bash (Bourne Again Shell) is the free and enhanced version of the Bourne shell distributed with Linux and GNU operating systems. Bash is similar to the original, but has added features such as command-line editing.

What does bash command line do?

bash is a sh-compatible command language interpreter that executes commands read from the standard input or from a file. bash also incorporates useful features from the Korn and C shells (ksh and csh).

How do you explain a command line?

A command line is a horizontal line on an interface that allows the user to type in various commands. Typically, there is a command prompt at the left side of a screen, with a blank line extending to the right where commands are typed.


2 Answers

Bash's process substitution replaces <( ... ) and >( ... ) with pipes from/to children. Hence the whole thing means "create a pipe from curl ..., and use it as stdin to bash".

Rather pointless, it would be better written

curl -L https://get.rvm.io | bash
like image 191
ephemient Avatar answered Oct 07 '22 02:10

ephemient


It's called process substitution. The ouput of the curl command is sent via an anonymous named pipe to the standard input of bash. Basically what that whole command is doing is executing what's retrieved by curl as a shell script.

I consider it risky, but some people seem to be OK with it. If you retrieve the file and run it in a separate step, though, you have an opportunity to inspect it first. Whatever you do, if you do it together don't run it as root or under sudo.

like image 29
Dennis Williamson Avatar answered Oct 07 '22 02:10

Dennis Williamson