From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3590 invoked by alias); 14 Sep 2011 19:37:11 -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: 16353 Received: (qmail 8613 invoked from network); 14 Sep 2011 19:37:09 -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,RCVD_IN_DNSWL_NONE,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=1316028703; bh=llP7Mhbn16RYKvyud4u4tw2ES7RT2wVAyCqKbZImfK4=; 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=hyLRdOBnk+5KOfpOIO255mclzgreOociNiCParI9KslJJ7XSUX1IBFUJNFK30thT7zZRre+N0enZbWD8a048Rw6TKIKxrwlcKrg/W8lrN2bq/JarFOGQS16wO44AGygsofzurydKIuxgVq5wPAvS5o44xGHGVwcD+9aIHH6/YnU= X-Yahoo-Newman-Id: 844077.21738.bm@smtp138.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: WEB4gAcVM1lqUqulfYj4QCggUuBvdSeY3YcSTmV_AAeXkrq Rl1PBjpqL X-Yahoo-SMTP: V1UR0WuswBDVD1eFhM33188Ir8ciBckz4W8ZMsAh Date: Wed, 14 Sep 2011 20:31:41 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: zsh-users@zsh.org Subject: Re: {fd}< and compound commands Message-ID: <20110914193141.GB7325@yahoo.fr> Mail-Followup-To: Peter Stephenson , zsh-users@zsh.org References: <20110914172148.GA7325@yahoo.fr> <20110914200601.72c91f87@pws-pc.ntlworld.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110914200601.72c91f87@pws-pc.ntlworld.com> User-Agent: Mutt/1.5.21 (2010-09-15) 2011-09-14 20:06:01 +0100, Peter Stephenson: [...] > { > exec {fd} > while read; do > ... > done <&$fd > } always { > exec {fd}<&- > } Thanks Peter, Why the "always" here? > (although in this particular case there's nothing to stop you doing > > while read var; do > ... > done > but I presume you have something more complicated in mind.) [...] Well, using fd 0 here is dangerous as you never know if commands in the loop will attempt to read from it (think of ssh without -n for instance), or you may actually want them to read from (the original) stdin. -- Stephane