zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: 4.3.12-test-2
Date: Sun, 23 Oct 2011 18:48:29 +0100	[thread overview]
Message-ID: <20111023184829.5aecffa5@pws-pc.ntlworld.com> (raw)
In-Reply-To: <20111023181918.1e8f0606@pws-pc.ntlworld.com>

On Sun, 23 Oct 2011 18:19:18 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      reply	other threads:[~2011-10-23 17:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20111020213929.410073fe@pws-pc.ntlworld.com>
     [not found] ` <20111021102007.GB23272@redoubt.spodhuis.org>
2011-10-21 11:08   ` 4.3.12-test-2 Peter Stephenson
2011-10-23 17:19     ` 4.3.12-test-2 Peter Stephenson
2011-10-23 17:48       ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111023184829.5aecffa5@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).