Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: {fd}< and compound commands



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