From 5e9c277f995c517e4403c87e74b758d5b65004f2 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Mon, 2 Mar 2015 20:06:17 +0000 Subject: tee: generalize the --write-error option to --output-error Adjust commit v8.23-140-gfdd6ebf to add the --output-error option instead of --write-error, and treat open() errors like write() errors. * doc/coreutils.texi (tee invocation): s/write-error/output-error/. * src/tee.c (main): Exit on open() error if appropriate. * tests/misc/tee.sh: Add a case to test open() errors. * NEWS: Adjust for the more general output error behavior. Suggested by Bernhard Voelker. --- tests/misc/tee.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/misc/tee.sh b/tests/misc/tee.sh index 84665cd00..f457a0b7a 100755 --- a/tests/misc/tee.sh +++ b/tests/misc/tee.sh @@ -64,7 +64,7 @@ if test -w /dev/full && test -c /dev/full; then fi -# Ensure tee honors --write-error modes +# Ensure tee honors --output-error modes mkfifo_or_skip_ fifo read_fifo() { timeout 10 dd count=1 if=fifo of=/dev/null status=none & } @@ -73,30 +73,36 @@ read_fifo yes >fifo pipe_status=$? -# Default operation is to exit silently on SIGPIPE +# Default operation is to continue on output errors but exit silently on SIGPIPE read_fifo -yes | returns_ $pipe_status timeout 10 tee 2>err >fifo || fail=1 -test $(wc -l < err) = 0 || { cat err; fail=1; } +yes | returns_ $pipe_status timeout 10 tee ./e/noent 2>err >fifo || fail=1 +test $(wc -l < err) = 1 || { cat err; fail=1; } # With -p, SIGPIPE is suppressed, exit 0 for EPIPE when all outputs finished read_fifo yes | timeout 10 tee -p 2>err >fifo || fail=1 test $(wc -l < err) = 0 || { cat err; fail=1; } -# With --write-error=warn, exit 1 for EPIPE when all outputs finished +# With --output-error=warn, exit 1 for EPIPE when all outputs finished +read_fifo +yes | returns_ 1 timeout 10 tee --output-error=warn 2>err >fifo || fail=1 +test $(wc -l < err) = 1 || { cat err; fail=1; } + +# With --output-error=exit, exit 1 immediately for EPIPE read_fifo -yes | returns_ 1 timeout 10 tee --write-error=warn 2>err >fifo || fail=1 +yes | returns_ 1 timeout 10 tee --output-error=exit /dev/null 2>err >fifo \ + || fail=1 test $(wc -l < err) = 1 || { cat err; fail=1; } -# With --write-error=exit, exit 1 immediately for EPIPE +# With --output-error=exit, exit 1 immediately on output error read_fifo -yes | returns_ 1 timeout 10 tee --write-error=exit /dev/null 2>err >fifo \ +yes | returns_ 1 timeout 10 tee --output-error=exit ./e/noent 2>err >fifo \ || fail=1 test $(wc -l < err) = 1 || { cat err; fail=1; } -# With --write-error=exit-nopipe, exit 0 for EPIPE +# With --output-error=exit-nopipe, exit 0 for EPIPE read_fifo -yes | timeout 10 tee --write-error=exit-nopipe 2>err >fifo || fail=1 +yes | timeout 10 tee --output-error=exit-nopipe 2>err >fifo || fail=1 test $(wc -l < err) = 0 || { cat err; fail=1; } wait -- cgit v1.2.3-70-g09d2