Bruno Haible wrote: > The Solaris 'diff' program understands option '-u', the AIX and HP-UX 'diff' > programs don't. So here's a proposed patch. It removes the spurious output > on all 3 platforms. > > 2011-11-12 Bruno Haible <br...@clisp.org> > > Silence successful tests that use 'compare' on AIX, HP-UX, Solaris. > * tests/init.sh (compare): Remove "No differences encountered" or > synonymous output from the 'diff' program.
Hi Bruno, Thanks for testing and noticing that. However, I would like to avoid using a temporary file when using GNU diff. How about something like this instead? diff_=$(diff -u "$0" "$0" < /dev/null 2> /dev/null) if test $? = 0; then if test -z "$diff_"; then compare () { diff -u "$@"; } else ... fi elif ... > --- tests/init.sh.orig Sat Nov 12 21:10:28 2011 > +++ tests/init.sh Sat Nov 12 21:10:27 2011 > @@ -222,9 +222,34 @@ > cleanup_ () { :; } > > if ( diff -u "$0" "$0" < /dev/null ) > /dev/null 2>&1; then > - compare () { diff -u "$@"; } > + 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 > + } > elif ( diff -c "$0" "$0" < /dev/null ) > /dev/null 2>&1; then > - compare () { diff -c "$@"; } > + 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 > + } > elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then > compare () { cmp -s "$@"; } > else