From 7ceaf1d975a17d07f1704d8edf4476218148cfba Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Fri, 20 Feb 2015 08:10:51 +0100 Subject: tee: treat '-' operand as file name as mandated by POSIX Since v5.2.1-1247-g8dafbe5, tee(1) treated '-' as stdout while POSIX explicitly requires to treat this as a file name. Revert this change, as the interleaved output - due to sending another copy of input to stdout - is not considered to be useful. Discussed in http://lists.gnu.org/archive/html/coreutils/2015-02/msg00085.html * src/tee.c (tee_files): Remove the special handling for "-" operands. (usage): Remove the corresponding sentence. * doc/coreutils.texi (common options): Remove the "tee -" example. (tee invocation): Document that tee(1) now treats "-" as a file name. * tests/misc/tee.sh: Add a test case for "tee -". While at it, re-indent the above multi-argument processing case and extend that to 13 operands, as POSIX mandates that, too. * tests/misc/tee-dash.sh: Remove now-obsolete test. * tests/local.mk (all_tests): Remove the above test. * NEWS (Changes in behavior): Mention the change. --- tests/misc/tee.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'tests/misc/tee.sh') diff --git a/tests/misc/tee.sh b/tests/misc/tee.sh index 5f2eeda7b..ecca6562b 100755 --- a/tests/misc/tee.sh +++ b/tests/misc/tee.sh @@ -20,17 +20,24 @@ print_ver_ tee echo line >sample || framework_failure_ -nums=$(seq 9) || framework_failure_ - -for n in 0 $nums; do - files=$(seq $n) - rm -f $files - tee $files out || fail=1 - for f in out $files; do - compare sample $f || fail=1 - done + +# POSIX says: "Processing of at least 13 file operands shall be supported." +for n in 0 1 2 12 13; do + files=$(seq $n) + rm -f $files + tee $files out || fail=1 + for f in out $files; do + compare sample $f || fail=1 + done done +# Ensure tee treats '-' as the name of a file, as mandated by POSIX. +# Between v5.3.0 and v8.23, a '-' argument caused tee to send another +# copy of input to standard output. +tee - out 2>err || fail=1 +compare sample ./- || fail=1 +compare sample out || fail=1 +compare /dev/null err || fail # Ensure tee exits early if no more writable outputs if test -w /dev/full && test -c /dev/full; then -- cgit v1.2.3-54-g00ecf