diff mbox series

[5/6] eval: Report I/O error on stdout

Message ID 20180907083414.14673-6-andrew.shadura@collabora.co.uk (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series [1/6] exec: Don't execute binary files if execve() returned ENOEXEC. | expand

Commit Message

Andrej Shadura Sept. 7, 2018, 8:34 a.m. UTC
From: Gerrit Pape <pape@smarden.org>

ENOSPC as a result of an echo builting failing gives no diagnostic.
Just as other shells, dash sets $? to 1, but aside from terminating
the script, this does not inform the user what the problem is:

zsh:
    % echo foo > /dev/full
    echo: write error: no space left on device

bash:
    $ echo foo > /dev/full
    bash: echo: write error: No space left on device

dash:
    $ echo foo > /dev/full
    [nothing]

Print an error to stderr like the other shells.

Suggested by Roger Leigh.

Signed-off-by: Gerrit Pape <pape@smarden.org>
[reworded the patch description with information from the bug]
Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
Bug-Debian: http://bugs.debian.org/690473
---
 src/eval.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/src/eval.c b/src/eval.c
index ee43fa9..231d3e0 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -955,6 +955,8 @@  evalbltin(const struct builtincmd *cmd, int argc, char **argv, int flags)
 	else
 		status = (*cmd->builtin)(argc, argv);
 	flushall();
+	if (outerr(out1))
+		warnx("%s: I/O error", commandname);
 	status |= outerr(out1);
 	exitstatus = status;
 cmddone: