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

Re: subtle `echo' bug

Bart Schaefer wrote:
> This affects any builtin that writes to its standard output, so the
> problem is almost certainly resulting from a write error on stdout
> because the builtin on the rightmost end of the pipeline is never
> reading from its stdin.

You can show this up with

trap '' PIPE

which causes zsh to report the error as a side effect (for reasons I
haven't investigated: possibly the error message isn't getting time to
emerge in the other case, which may be a bug).  Alexey's original
example now gives variations on:

% seq 1 3 | while read n; do { echo | echo } | echo $n ; done
echo: write error: broken pipe
zsh: write error: broken pipe

The numbers always come out because the error is trapped, but the
messages show where the write failed because of SIGPIPE.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.


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