Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: {fd}< and compound commands
- X-seq: zsh-users 16354
 
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
 
- To: zsh-users@xxxxxxx
 
- Subject: Re: {fd}< and compound commands
 
- Date: Wed, 14 Sep 2011 22:05:35 +0100
 
- In-reply-to: Message from Stephane Chazelas <stephane_chazelas@yahoo.fr>   of "Wed, 14 Sep 2011 20:31:41 BST." <20110914193141.GB7325@yahoo.fr>
 
- List-help: <mailto:zsh-users-help@zsh.org>
 
- List-id: Zsh Users List <zsh-users.zsh.org>
 
- List-post: <mailto:zsh-users@zsh.org>
 
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
 
Stephane Chazelas wrote:
> 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?
That's extended { ... } syntax to ensure the clean-up gets executed even
if there's an error in the main block.  In fact, if I'd known Ruby when
I wrote it, I'd probably have called it "ensure" instead.
-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author