From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3515 invoked by alias); 23 Oct 2011 17:56:10 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29845 Received: (qmail 13182 invoked from network); 23 Oct 2011 17:55:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.171 is neither permitted nor denied by SPF record at ntlworld.com) X-ProxyUser-IP: 86.6.29.42 Date: Sun, 23 Oct 2011 18:48:29 +0100 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: 4.3.12-test-2 Message-ID: <20111023184829.5aecffa5@pws-pc.ntlworld.com> In-Reply-To: <20111023181918.1e8f0606@pws-pc.ntlworld.com> References: <20111020213929.410073fe@pws-pc.ntlworld.com> <20111021102007.GB23272@redoubt.spodhuis.org> <20111021120848.252c5811@pwslap01u.europe.root.pri> <20111023181918.1e8f0606@pws-pc.ntlworld.com> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 23 Oct 2011 18:19:18 +0100 Peter Stephenson wrote: > Could do with a test. This revealed that the existing tests actually expected errors on closing stdout or stdin, which doesn't really make sense. I think what confused me is I did expect errors with "print >&-", but we don't get them (though we do with "exec >&-; print". This seems to be a deliberate special case. We do an untested fwrite() followed by /* Testing EBADF special-cases >&- redirections */ if ((fout != stdout) ? (fclose(fout) != 0) : (fflush(fout) != 0 && errno != EBADF)) { zwarnnam(name, "write error: %e", errno); ret = 1; } This looks pretty flaky to me but there must be some history behind it. Index: Test/A04redirect.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v retrieving revision 1.19 diff -p -u -r1.19 A04redirect.ztst --- Test/A04redirect.ztst 27 Jul 2011 19:14:18 -0000 1.19 +++ Test/A04redirect.ztst 23 Oct 2011 17:41:57 -0000 @@ -156,11 +156,14 @@ read foo <&-) 1:'<&-' redirection ?(eval):1: failed to close file descriptor 3: bad file descriptor -?(eval):2: failed to close file descriptor 0: bad file descriptor print foo >&- 0:'>&-' redirection -?(eval):1: failed to close file descriptor 1: bad file descriptor + + (exec >&- + print foo) +0:'>&-' with attempt to use closed fd +?(eval):2: write error: bad file descriptor fn() { local foo; read foo; print $foo; } coproc fn -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/