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

Re: [BUG] builtin echo doesn't check write error



On 2021-06-09 19:16:17 +0100, Stephane Chazelas wrote:
> 2011 workers/29845 Peter notices the error is displayed in
>      (exec >&-; print) and adds a test case for it, but I'm not
>      sure he correctly identified why.

I also find this disturbing:

zira% (exec >&-; echo)
zsh: write error: bad file descriptor
zira% (exec >&-; echo >&-)
zira% 

(or with "print" instad of "echo").

> POSIX does say that printf/echo should return with a non-zero
> exit status upon error, and stderr be used for diagnostix
> errors as usual. It's not clear to me if implementations are at
> liberty to decide whether a write() error is considered an error
> or not.

Well, in almost all cases, e.g. when the close is not in the same
command, and when this is not fd 1 (stdout), but other fd, such as
in "echo foo 3>&- >&3", one gets an error. So this is already very
inconsistent.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




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