The RVM homepage
http://rvm.io/
recommends people install RVM using
bash < <( curl http://rvm.io/releases/rvm-install-head )
What is this syntax? command <( another_command)
Can't the original line be? curl http://rvm.io/releases/rvm-install-head | bash
<(command)
creates a named pipe with the output of the command (or uses an existing /dev/fd
file), and substitutes the filename of that pipe into the command. <
then redirects standard input from that given file.
So yes, in this case, this is equivalent to
curl http://rvm.io/releases/rvm-install-head | bash
I'm not sure why they suggest the more complicated and less portable version. In some cases, you would prefer the version using < <()
to the version using a pipe, as the pipe creates a subshell for the command receiving input (in this case, bash
), while the < <()
creates a subshell for the command producing output. If you use a pipe, then the command in the subshell can't modify variables in the shell environment, which is sometimes desired (if you wanted to pipe something to a while read ...
command). However, in this case, the output of the command is just being passed directly to an explicit invocation of bash
; there is nothing that needs to be run from the parent shell here.
See part 23 of the advanced bash scripting guide.
In short, the effect of the <( x )
and >( y )
syntaxes are the following:
You put them in your command line where a filename is expected
Enclosed command will either
<(x)
), or>(y)
)a temporary file (or a named pipe, bash will manage it), the name of which will be given to your external command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With