syntax:expansion:proc_subst

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
syntax:expansion:proc_subst [2018/03/02 09:54]
centos-hater [Avoiding subshells] Grammar fix
syntax:expansion:proc_subst [2021/04/11 18:56] (current)
powerbasher
Line 21: Line 21:
  
 ==== Scope ==== ==== Scope ====
 +<note important>​
 +Note: According to multiple comments and sources, the scope of process substitution file descriptors is **not** stable, guaranteed, or specified by bash. Newer versions of bash (5.0+) seem to have shorter scope, and substitutions scope seems to be shorter than function scope.
 +See [[https://​unix.stackexchange.com/​questions/​425456/​conditional-process-substitution|stackexchange]] and [[https://​stackoverflow.com/​questions/​46660020/​bash-what-is-the-scope-of-the-process-substitution|stackoverflow]];​ the latter discussion contains a script that can test the scoping behavior case-by-case
 +</​note>​
  
 If a process substitution is expanded as an argument to a function, expanded to an environment variable during calling of a function, or expanded to any assignment within a function, the process substitution will be "held open" for use by any command within the function or its callees, until the function in which it was set returns. If the same variable is set again within a callee, unless the new variable is local, the previous process substitution is closed and will be unavailable to the caller when the callee returns. If a process substitution is expanded as an argument to a function, expanded to an environment variable during calling of a function, or expanded to any assignment within a function, the process substitution will be "held open" for use by any command within the function or its callees, until the function in which it was set returns. If the same variable is set again within a callee, unless the new variable is local, the previous process substitution is closed and will be unavailable to the caller when the callee returns.
  • syntax/expansion/proc_subst.txt
  • Last modified: 2021/04/11 18:56
  • by powerbasher