From c69b149cb5ce6446eb267074f640e34ca726a45d Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 14 Apr 2005 16:24:42 +0000 Subject: 21141: fix some issues associated with the {myfd}>... syntax --- Doc/Zsh/redirect.yo | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Doc/Zsh/redirect.yo') 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 &$myfd). + Note that a pipe is an implicit redirection; thus example(cat bar | sort