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

Re: Test failure in redirect.

On Feb 5,  2:46am, Zefram wrote:
} Is there any precedent for echo/print being silent about a closed stdout
} but complaining about other error conditions?

I'd be happy with reverting it to the old state where it was silent about
all write errors.  It was changed because of a Debian bug report; the
precedent, if any, was embodied in A04redirect.ztst.

We generally haven't created tests for behavior that was known to be wrong
without in some way marking it as such.  As the test code from more than a
year ago was specifically testing for successful exit of print to a closed
stdout, somebody (probably PWS) must at some point have believed that to
be the correct behavior.

} The only argument I see for not treating a closed stdout as an error
} when one attempts to write to it is to allow >&- to be used to throw
} away output.  What's wrong with >/dev/null?

There's no requirement that /dev/null exist in order for zsh to compile
and run.  There has in the past been a pure Windows port of zsh, even
though it's sort of been superceded by the Cygwin build now.

} Is there a significant amount of code that uses >&- instead of >/dev/null?

I couldn't say if there's a "significant" amount, but closing stdout to
supress output was not an uncommon scripting hack in the past.  (I'd say
the "distant" past, but that would make me feel old.)

} >E.g. here's bash:
} >
} >[schaefer@zagzig schaefer]$ echo foo >&-
} >[schaefer@zagzig schaefer]$ echo $?
} >0
} >[schaefer@zagzig schaefer]$ 
} I get results inconsistent with that:
} 	zefram@bowl:~> echo foo >&-; echo $?
} 	1
} 	zefram@bowl:~> echo foo >/dev/full; echo $?
} 	1

I get $? of 0 for both of those, with bash-2.0.3.  So even returning an
error status is a fairly recent development.

} How does your version handle >/dev/full?

bash-2.0.3 gives no error message and returns 0 on write to /dev/full.
(I verified that `cat > /dev/full' on the same machine gives the "no
space on device" error.)

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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