Reputation: 1059
#1
f() {
cat "$1" >"$x"
}
#2
x=>(tr '[:lower:]' '[:upper:]') f <(echo 'hi there')
In #2 which part is executed first? x=>(tr '[:lower:]' '[:upper:]')
or f <(echo 'hi there')
. Is #2 is a compound compound or a single command?
Upvotes: 0
Views: 40
Reputation: 295403
A single command can have any number of var=value
prefixes; 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.
"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. (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).
Upvotes: 3