Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: {fd}< and compound commands
- X-seq: zsh-users 16380
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: {fd}< and compound commands
- Date: Sat, 17 Sep 2011 13:21:32 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1316262094; bh=1j0zJpFr+d64wzlHdmz+BwPH3IBLgiN/kJSLS5nmitc=; 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=ohh+vyLhvYayekbaY9etpCHElU1c7Ms+B80OLWxdwuUMHft8EuO4M+KgVUkCg/t7axAj1qn2OHYB1SnlHLakTuOfzMzaMXULn/gHnNP3z2JjU6yVg4X7zcYhrJ4ebBNUyJjjuW8I4MYpuHv3e9Q1PiqkdhgyCjWWHvpj4aVHXcw=
- 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:
[...]
> You need to do:
>
> local fd
>
> {
> exec {fd}<file
>
> while read; do
> ...
> done <&$fd
> } always {
> exec {fd}<&-
> }
[...]
Except that if the first exec fails, that might close the wrong
fd.
Maybe:
if command exec {fd}<file; then
{
while read <&$fd; do
...
done
} always {
exec {fd}<&-
}
fi
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author