From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10414 invoked from network); 14 Apr 2005 14:23:55 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 Apr 2005 14:23:55 -0000 Received: (qmail 2257 invoked from network); 14 Apr 2005 14:23:50 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Apr 2005 14:23:50 -0000 Received: (qmail 2302 invoked by alias); 14 Apr 2005 14:23:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21140 Received: (qmail 2293 invoked from network); 14 Apr 2005 14:23:46 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 14 Apr 2005 14:23:46 -0000 Received: (qmail 1969 invoked from network); 14 Apr 2005 14:23:46 -0000 Received: from vms040pub.verizon.net (206.46.252.40) by a.mx.sunsite.dk with SMTP; 14 Apr 2005 14:23:40 -0000 Received: from candle.brasslantern.com ([4.11.1.68]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IEX00LTWXBF6NB5@vms040.mailsrvcs.net> for zsh-workers@sunsite.dk; Thu, 14 Apr 2005 09:23:40 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j3EENcVw014044 for ; Thu, 14 Apr 2005 07:23:38 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j3EENcf7014043 for zsh-workers@sunsite.dk; Thu, 14 Apr 2005 07:23:38 -0700 Date: Thu, 14 Apr 2005 14:23:37 +0000 From: Bart Schaefer Subject: Re: PATCH: allocating a new file descriptor In-reply-to: <200504140949.j3E9n5Kp006216@news01.csr.com> To: zsh-workers@sunsite.dk (Zsh hackers list) Message-id: <1050414142337.ZM14042@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <200504121257.j3CCvkXr003286@news01.csr.com> <1050414045748.ZM13551@candle.brasslantern.com> <200504140949.j3E9n5Kp006216@news01.csr.com> Comments: In reply to Peter Stephenson "Re: PATCH: allocating a new file descriptor" (Apr 14, 10:49am) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Apr 14, 10:49am, Peter Stephenson wrote: } Subject: Re: PATCH: allocating a new file descriptor } } I can add documentation to point this out if you think it would be } useful. Possibly so. } It would also be possible to make NO_CLOBBER check that in {myfd}>stuff, } $myfd doesn't already point to an fd with an FDT_EXTERNAL flag. That } would prevent overwriting. I quite like that idea. I do, too. } For more complicated cases you might need to set myfd to 0 first Or (more appropriately, I would think) unset it, no? (Given discipline functions, one could even arrange that myfd closes its descriptor upon unset.) } Fortuitously, } } print This is a log file {myfd}>~/tmp/logfile.txt >&$myfd } } works; $myfd is substituted at the right point. That's quite lucky, } since most expansions have been done by this point. At first I thought that was a little odd, but I guess really it's OK, because this ... print ${myfd::=2} $myfd ... also prints "2 2". It might be useful to add a note somewhere (the "Expansion" section?) about the ordering of parameter expansion relative to redirections. } However, there's also the point that if you use this after an external } command the shell has already forked and the fd doesn't appear in the } parent shell. That's a very interesting point. This works: /bin/echo foo {myfd}>>(tr a-z A-Z) >&$myfd But this causes the shell to hang forever: print foo {myfd}>>(tr a-z A-Z) >&$myfd -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net