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

Re: 4.3.12-test-2



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



Messages sorted by: Reverse Date, Date, Thread, Author