summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-06-17 09:02:09 +0200
committerJim Meyering <meyering@redhat.com>2011-06-17 09:17:30 +0200
commit13672ec3211a5a77caf16dc24b83100d57e2a2ec (patch)
tree243b742463f3249cf84bf75446111d6867517370 /tests
parent7f8d9892fb4ce29821fc824defaa6e0d32740feb (diff)
downloadcoreutils-13672ec3211a5a77caf16dc24b83100d57e2a2ec.tar.xz
tests: make init.sh's warn_ emit to both the tty and the log file
* tests/init.sh (warn_): When $stderr_fileno_ != 2, emit the diagnostic to both the tty and the log file.
Diffstat (limited to 'tests')
-rw-r--r--tests/init.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/init.sh b/tests/init.sh
index 5f06b5e0a..d7a5d8347 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -75,8 +75,12 @@ Exit () { set +e; (exit $1); exit $1; }
: ${stderr_fileno_=2}
# Call w2_ only via warn_, since correct expansion of "$*" depends on
-# IFS starting with ' '.
-w2_ () { printf '%s\n' "$*" 1>&$stderr_fileno_ ; }
+# IFS starting with ' '. Always write the full diagnostic to stderr.
+# When stderr_fileno_ is not 2, also emit the first line of the
+# diagnostic to that file descriptor.
+w2_ () { printf '%s\n' "$*" >&2
+ test $stderr_fileno_ = 2 \
+ || { printf '%s\n' "$*" | head -1 >&$stderr_fileno_ ; } ; }
warn_ ()
{
# If IFS does not start with ' ', set it and emit the warning in a subshell.