about summary refs log tree commit diff
path: root/Doc/Zsh/redirect.yo
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-04-14 16:24:42 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-04-14 16:24:42 +0000
commitc69b149cb5ce6446eb267074f640e34ca726a45d (patch)
treeb083574ada7a063034f89949d5aa332d3b79b7e1 /Doc/Zsh/redirect.yo
parent24c329275a1620accf3121cdc9c53daf9bd606bd (diff)
downloadzsh-c69b149cb5ce6446eb267074f640e34ca726a45d.tar.gz
zsh-c69b149cb5ce6446eb267074f640e34ca726a45d.tar.xz
zsh-c69b149cb5ce6446eb267074f640e34ca726a45d.zip
21141: fix some issues associated with the {myfd}>... syntax
Diffstat (limited to 'Doc/Zsh/redirect.yo')
-rw-r--r--Doc/Zsh/redirect.yo25
1 files changed, 25 insertions, 0 deletions
diff --git a/Doc/Zsh/redirect.yo b/Doc/Zsh/redirect.yo
index 3ce4b4369..ba4d17a55 100644
--- a/Doc/Zsh/redirect.yo
+++ b/Doc/Zsh/redirect.yo
@@ -174,6 +174,27 @@ parameter is readonly.  However, it is not an error to read or write a file
 descriptor using tt(<&$)var(param) or tt(>&$)var(param) if var(param) is
 readonly.
 
+If the option tt(CLOBBER) is unset, it is an error to open a file
+descriptor using a parameter that is already set to an open file descriptor
+previously allocated by this mechanism.  Unsetting the parameter before
+using it for allocating a file descriptor avoids the error.
+
+Note that this mechanism merely allocates or closes a file descriptor; it
+does not perform any redirections from or to it.  It is usually convenient
+to allocate a file descriptor prior to use as an argument to tt(exec).  The
+following shows a typical sequence of allocation, use, and closing of a
+file descriptor:
+
+example(integer myfd
+exec {myfd}>~/logs/mylogfile.txt
+print This is a log message. >&$myfd
+exec {myfd}>&-)
+
+Note that the expansion of the variable in the expression tt(>&$myfd)
+occurs at the point the redirection is opened.  This is after the expansion
+of command arguments and after any redirections to the left on the command
+line have been processed.
+
 The `tt(|&)' command separator described in
 ifzman(em(Simple Commands & Pipelines) in zmanref(zshmisc))\
 ifnzman(noderef(Simple Commands & Pipelines))
@@ -230,6 +251,10 @@ example(sort <f{oo,ubar})
 
 is equivalent to `tt(cat foo fubar | sort)'.
 
+Expansion of the redirection argument occurs at the point the redirection
+is opened, at the point described above for the expansion of the variable
+in tt(>&$myfd).
+
 Note that a pipe is an implicit redirection; thus
 
 example(cat bar | sort <foo)