简体   繁体   中英

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? x=>(tr '[:lower:]' '[:upper:]') or f <(echo 'hi there') . Is #2 is a compound compound or a single command?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM