# the reason for skip/failure to console, rather than to the .log files.
: ${stderr_fileno_=2}
-warn_ () { echo "$@" 1>&$stderr_fileno_; }
+# Note that correct expansion of "$*" depends on 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.
+warn_ ()
+{
+ # If IFS does not start with ' ', set it and emit the warning in a subshell.
+ case $IFS in
+ ' '*) printf '%s\n' "$*" >&2
+ test $stderr_fileno_ = 2 \
+ || { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;;
+ *) (IFS=' '; warn_ "$@");;
+ esac
+}
fail_ () { warn_ "$ME_: failed test: $@"; Exit 1; }
skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; }
fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; }
# a partition, or to undo any other global state changes.
cleanup_ () { :; }
-if ( diff -u "$0" "$0" < /dev/null ) > /dev/null 2>&1; then
- compare () { diff -u "$@"; }
-elif ( diff -c "$0" "$0" < /dev/null ) > /dev/null 2>&1; then
- compare () { diff -c "$@"; }
+if diff_out_=`( diff -u "$0" "$0" < /dev/null ) 2>/dev/null`; then
+ if test -z "$diff_out_"; then
+ compare () { diff -u "$@"; }
+ else
+ compare ()
+ {
+ if diff -u "$@" > diff.out; then
+ # No differences were found, but Solaris 'diff' produces output
+ # "No differences encountered". Hide this output.
+ rm -f diff.out
+ true
+ else
+ cat diff.out
+ rm -f diff.out
+ false
+ fi
+ }
+ fi
+elif diff_out_=`( diff -c "$0" "$0" < /dev/null ) 2>/dev/null`; then
+ if test -z "$diff_out_"; then
+ compare () { diff -c "$@"; }
+ else
+ compare ()
+ {
+ if diff -c "$@" > diff.out; then
+ # No differences were found, but AIX and HP-UX 'diff' produce output
+ # "No differences encountered" or "There are no differences between the
+ # files.". Hide this output.
+ rm -f diff.out
+ true
+ else
+ cat diff.out
+ rm -f diff.out
+ false
+ fi
+ }
+ fi
elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
compare () { cmp -s "$@"; }
else