这是什么意思&QUOT;庆典&LT; ≤(卷曲http://rvm.io/releases/rvm-install-head)QUOT; [英] What does it mean "bash < <( curl http://rvm.io/releases/rvm-install-head )"
问题描述
在RVM首页
建议人们使用安装RVM
recommends people install RVM using
bash < <( curl http://rvm.io/releases/rvm-install-head )
这是什么语法? 命令&lt;(another_command)
不能原线是什么? 卷曲http://rvm.io/releases/rvm-install-head |庆典
推荐答案
≤(命令)
创建一个带有命令的输出命名管道(或使用现有的/ dev / FD
文件),并替换该管道的文件名到命令。 &LT;
然后重定向从给定文件的标准输入
<(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
我不知道为什么他们建议比较复杂,不便于携带的版本。在某些情况下,你会使用preFER版本&LT; ≤()
来使用管道,如管道创造了命令接收输入子外壳的版本(在此情况下,的bash
),而&LT; ≤()
创建命令产生输出子shell。如果您使用的管道,然后在子shell命令不能修改外壳环境下,有时需要的变量(如果你想管的东西到而读...
命令)。然而,在这种情况下,命令的输出只是被直接传递到的的bash
显式调用;没有什么需要从这里父shell中运行。
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.
这篇关于这是什么意思&QUOT;庆典&LT; ≤(卷曲http://rvm.io/releases/rvm-install-head)QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!