[英]How does “var=>(…) somecommand” work?
#1
f() {
cat "$1" >"$x"
}
#2
x=>(tr '[:lower:]' '[:upper:]') f <(echo 'hi there')
In #2 which part is executed first? 在#2中,哪个部分首先执行?
x=>(tr '[:lower:]' '[:upper:]')
or f <(echo 'hi there')
. x=>(tr '[:lower:]' '[:upper:]')
或f <(echo 'hi there')
。 Is #2 is a compound compound or a single command? #2是复合化合物还是单个命令?
A single command can have any number of var=value
prefixes; 一个命令可以具有任意数量的
var=value
前缀; these variables are exported to the environment for the duration of that single command, and do not exist later. 这些变量将在该单个命令的持续时间内导出到环境,以后将不存在。 This isn't bash-specific, but is part of the POSIX sh standard.
这不是bash特定的,而是POSIX sh标准的一部分。
"Which part is executed first?" “首先执行哪个部分?” isn't a meaningful question.
不是一个有意义的问题。 The process substitution whose FIFO's filename (being a
/dev/fd
entry and an anonymous FIFO if the OS permits same) is stored in X is started first, but execution is asynchronous. 首先开始在X中存储其FIFO的文件名(如果操作系统允许,则为
/dev/fd
条目和匿名FIFO)的进程替换,但执行是异步的。 (That said, because the output of the process substitution writing hi there
is redirected as input for the one running tr
, the one with the echo
necessarily blocks until tr
is ready to read what it's writing). (这就是说,因为进程替代写入
hi there
的输出被重定向为一个正在运行的tr
输入,所以具有echo
那个必须阻塞,直到tr
准备读取其正在写入的内容为止)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.