From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27651 invoked by alias); 14 Sep 2011 19:06:14 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16352 Received: (qmail 17157 invoked from network); 14 Sep 2011 19:06:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.43 is neither permitted nor denied by SPF record at ntlworld.com) X-ProxyUser-IP: 81.97.71.129 Date: Wed, 14 Sep 2011 20:06:01 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: {fd}< and compound commands Message-ID: <20110914200601.72c91f87@pws-pc.ntlworld.com> In-Reply-To: <20110914172148.GA7325@yahoo.fr> References: <20110914172148.GA7325@yahoo.fr> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 14 Sep 2011 18:21:48 +0100 Stephane Chazelas wrote: > $ zsh -c '{echo foo >&$fd;} {fd}> a' > zsh:1: parse error near `{' > (same for while/do/done constructs at least) > > Is that the expected behavior? I can't see it being documented. It is documented now. This is all complicated stuff with wide implications for the parser; there's is no chance I will have to time to change it myself. > That would be useful in > > while read <&$fd var; do > ... > done {fd}< file > > to avoid having to worry about overriding fds 3-9. There's no code automatically to close file descriptors anyway. Generally, that syntax isn't doing quite what the use of redirection syntax would suggest; it's permanently opening a file descriptor, not performing a possibly temporary redirection. You need to do: local fd { exec {fd} Web page now at http://homepage.ntlworld.com/p.w.stephenson/