Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: {fd}< and compound commands
- X-seq: zsh-users 16368
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- To: Chet Ramey <chet.ramey@xxxxxxxx>
- Subject: Re: {fd}< and compound commands
- Date: Thu, 15 Sep 2011 15:21:30 +0100
- Cc: Peter Stephenson <Peter.Stephenson@xxxxxxx>, zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1316096492; bh=p4znCzBCSeb1PxD8J3iETzV65be7ir7xHZ6S9QbKJ0w=; 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=TRbR1xQFd1As0otc9oYGn9bNk3x/MkseYvexUWJ54OawMlCZj/7MZMwWczi9cBW8AIVXXXtfzwwErs2qBxW9wzagZNLyUkhZu1Na6VHN6lOjIydUFwL+2WwfmWDrJA7rDLZ+QuCWsmlZXHgB7FsFio68IC4Y5/l/slolW4ZR4oc=
- In-reply-to: <4E71FC1B.8080608@case.edu>
- 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: Chet Ramey <chet.ramey@xxxxxxxx>, Peter Stephenson <Peter.Stephenson@xxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20110914172148.GA7325@yahoo.fr> <20110914200601.72c91f87@pws-pc.ntlworld.com> <20110915125822.GB5497@yahoo.fr> <20110915140926.56a83d9e@pwslap01u.europe.root.pri> <4E71FC1B.8080608@case.edu>
2011-09-15 09:22:35 -0400, Chet Ramey:
> On 9/15/11 9:09 AM, Peter Stephenson wrote:
>
> >> does that feature come from another shell/language?
> >
> > Yes, we discussed it. I think one of us (not me) suggested the syntax.
>
> Oliver Kiddle.
[...]
Oh, I hadn't realised bash supported it too (since
bash-4.1-alpha according to CHANGES).
For completeness, looks like bash behaves like ksh93 (no close,
works with compound commands).
So looks like if we want to be portable accross all 3 shells,
we'd need to write it:
exec {fd}> file
... >&$fd
exec {fd}>&-
BTW, zsh protects its own internal fds. Looks like bash and
ksh93 don't:
~$ zsh -c 'fd=11; exec {fd}>&-'
zsh:1: file descriptor 11 used by shell, not closed
~$ bash -c 'fd=10; { exec {fd}>&-; } 2> /dev/null; echo test >&2'
~$ ksh93 -c 'fd=10; { exec {fd}>&-; } 2> /dev/null; echo test >&2'
~$
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author