From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15428 invoked by alias); 15 Sep 2011 14:27:53 -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: 16368 Received: (qmail 2629 invoked from network); 15 Sep 2011 14:27:51 -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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at yahoo.fr does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1316096492; bh=p4znCzBCSeb1PxD8J3iETzV65be7ir7xHZ6S9QbKJ0w=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent; b=TRbR1xQFd1As0otc9oYGn9bNk3x/MkseYvexUWJ54OawMlCZj/7MZMwWczi9cBW8AIVXXXtfzwwErs2qBxW9wzagZNLyUkhZu1Na6VHN6lOjIydUFwL+2WwfmWDrJA7rDLZ+QuCWsmlZXHgB7FsFio68IC4Y5/l/slolW4ZR4oc= X-Yahoo-Newman-Id: 446312.43842.bm@smtp131.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: rYOl8sQVM1mZxA1DFiEUpGrsSPfim6pel6cT7RnytrvAzDM O3xfRMEfHZ2ST549HLIE2MqcaOpWL7xbzkWpTvkzT2QsK.uZmO6wB3.ghFkY kDUYvpXQvPHoOjn96QzMEZAJt5Lw.e7FrvWfgRBBHndHtnycX6v2nCAsdNIB eVRrl_ifJ.tT4K3RIvs1WLi33o9szP26_UiqCQXjoXSyal32jJJcYNXtJy1g wur2ohb94UPtDq4pOKk0NHEKYC2niUfd7umNFfYw.uCtt_tNSLTwk6Z_9Mj4 n5N6Am1zWMjnNnuGM4YLJ.itTyUbhbqNs1QTpsg89Grlfztv9wMON5DQtefN uEQT5NA9T6eSMdKzR3GNvh3Jwz9L9XpEGrwiAdBOAXrFJGGrmAtZy X-Yahoo-SMTP: V1UR0WuswBDVD1eFhM33188Ir8ciBckz4W8ZMsAh Date: Thu, 15 Sep 2011 15:21:30 +0100 From: Stephane Chazelas To: Chet Ramey Cc: Peter Stephenson , zsh-users@zsh.org Subject: Re: {fd}< and compound commands Message-ID: <20110915142130.GC5497@yahoo.fr> Mail-Followup-To: Chet Ramey , Peter Stephenson , zsh-users@zsh.org References: <20110914172148.GA7325@yahoo.fr> <20110914200601.72c91f87@pws-pc.ntlworld.com> <20110915125822.GB5497@yahoo.fr> <20110915140926.56a83d9e@pwslap01u.europe.root.pri> <4E71FC1B.8080608@case.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E71FC1B.8080608@case.edu> User-Agent: Mutt/1.5.21 (2010-09-15) 2011-09-15 09:22:35 -0400, Chet Ramey: > On 9/15/11 9:09 AM, Peter Stephenson wrote: > > >> does that feature come from another shell/language? > > > > Yes, we discussed it. I think one of us (not me) suggested the syntax. > > Oliver Kiddle. [...] Oh, I hadn't realised bash supported it too (since bash-4.1-alpha according to CHANGES). For completeness, looks like bash behaves like ksh93 (no close, works with compound commands). So looks like if we want to be portable accross all 3 shells, we'd need to write it: exec {fd}> file ... >&$fd exec {fd}>&- BTW, zsh protects its own internal fds. Looks like bash and ksh93 don't: ~$ zsh -c 'fd=11; exec {fd}>&-' zsh:1: file descriptor 11 used by shell, not closed ~$ bash -c 'fd=10; { exec {fd}>&-; } 2> /dev/null; echo test >&2' ~$ ksh93 -c 'fd=10; { exec {fd}>&-; } 2> /dev/null; echo test >&2' ~$ -- Stephane