about summary refs log tree commit diff
path: root/Doc
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2012-10-18 16:18:57 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2012-10-18 16:18:57 +0000
commit02225925efc7152b52045049e33ceb76b12819dc (patch)
tree1941c6b2c3aae8ea27b24f669e9a2e9fa2df1dc6 /Doc
parenta02f3b69102b0e1d0541eeb5715197e08e1d21ab (diff)
downloadzsh-02225925efc7152b52045049e33ceb76b12819dc.tar.gz
zsh-02225925efc7152b52045049e33ceb76b12819dc.tar.xz
zsh-02225925efc7152b52045049e33ceb76b12819dc.zip
30740: add example of process substitution using anonymous function
Diffstat (limited to 'Doc')
-rw-r--r--Doc/Zsh/expn.yo18
1 files changed, 18 insertions, 0 deletions
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 18d0447f3..9d6b5c3b5 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -483,6 +483,24 @@ example(LPAR()mycmd =(myoutput)RPAR() &!)
 as the forked subshell will wait for the command to finish then remove
 the temporary file.
 
+A general workaround to ensure a process substitution endures for
+an appropriate length of time is to pass it as a parameter to
+an anonymous shell function (a piece of shell code that is run
+immediately with function scope).  For example, this code:
+
+example(LPAR()RPAR() {
+   print File $1:
+   cat $1
+} =+LPAR()print This be the verse+RPAR())
+
+outputs something resembling the following
+
+example(File /tmp/zsh6nU0kS:
+This be the verse)
+
+The temporary file created by the process substitution will be deleted
+when the function exits.
+
 texinode(Parameter Expansion)(Command Substitution)(Process Substitution)(Expansion)
 sect(Parameter Expansion)
 cindex(parameter expansion)