Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: {fd}< and compound commands
- X-seq: zsh-users 16353
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: {fd}< and compound commands
- Date: Wed, 14 Sep 2011 20:31:41 +0100
- Cc: zsh-users@xxxxxxx
- 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=
- In-reply-to: <20110914200601.72c91f87@pws-pc.ntlworld.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20110914172148.GA7325@yahoo.fr> <20110914200601.72c91f87@pws-pc.ntlworld.com>
2011-09-14 20:06:01 +0100, Peter Stephenson:
[...]
> {
> exec {fd}<file
>
> 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 <file
>
> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author