]> Savannah Git Hosting - gnulib.git/commitdiff
tests/init.sh: port Alpine fix to AIX 7.1
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 25 Sep 2016 03:13:43 +0000 (20:13 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 25 Sep 2016 03:17:14 +0000 (20:17 -0700)
* tests/init.sh (compare_): When attempting to use diff -U3,
prefer diff -u to -U3 to -c to plain diff.  Do not insist on

ChangeLog
tests/init.sh
tests/test-init.sh

index cd12f943037c5f3d1251749c619e8a812a829a78..b006ef07efc174c3e231a4c8150d928507dcbfe1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2016-09-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       tests/init.sh: port Alpine fix to AIX 7.1
+       * tests/init.sh (compare_): When attempting to use diff -U3,
+       prefer diff -u to -U3 to -c to plain diff.  Do not insist on
+       diff -u not outputting a space after leading '+', as the users
+       of 'compare' should not be that picky about its output format.
+       In the AIX 7.1 case, return with diff exit status (or with 2 if
+       trouble), instead of some random nonzero exit status.
+       * tests/test-init.sh (test_compare): Remove space after leading
+       '+', so that AIX 7.1 'diff' passes the test.
+
 2016-09-22  Paul Eggert  <eggert@cs.ucla.edu>
 
        nl_langinfo: pacify GCC
index 09b07394f9e90422f04e0d803cc651aef65d4748..da743c2ab0dd1f2e88dcf4ca7770b2c137b6a250 100644 (file)
@@ -295,50 +295,24 @@ compare_dev_null_ ()
   return 2
 }
 
-if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < /dev/null` \
-   && diff -u Makefile "$0" 2>/dev/null | grep '^[+]#!' >/dev/null; then
-  # diff accepts the -u option and does not (like AIX 7 'diff') produce an
-  # extra space on column 1 of every content line.
-  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
-  for diff_opt_ in -U3 -c '' no; do
-    test "$diff_opt_" = no && break
-    diff_out_=`exec 2>/dev/null; diff $diff_opt_ "$0" "$0" </dev/null` && break
-  done
-  test "$diff_opt_" != no
-then
+for diff_opt_ in -u -U3 -c '' no; do
+  test "$diff_opt_" != no &&
+    diff_out_=`exec 2>/dev/null; diff $diff_opt_ "$0" "$0" < /dev/null` &&
+    break
+done
+if test "$diff_opt_" != no; then
   if test -z "$diff_out_"; then
     compare_ () { diff $diff_opt_ "$@"; }
   else
     compare_ ()
     {
-      if diff $diff_opt_ "$@" > 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
+      # If no differences were found, AIX and HP-UX 'diff' produce output
+      # like "No differences encountered".  Hide this output.
+      diff $diff_opt_ "$@" > diff.out
+      diff_status_=$?
+      test $diff_status_ -eq 0 || cat diff.out || diff_status_=2
+      rm -f diff.out || diff_status_=2
+      return $diff_status_
     }
   fi
 elif cmp -s /dev/null /dev/null 2>/dev/null; then
index 1dd05f4504501a08ecc1cd146b9c2a2fc40783fa..a6278599adaa4283ce0b588ff6972be192cf30b4 100755 (executable)
@@ -57,7 +57,8 @@ EOF
     # Also remove the @@ line, since Solaris 5.10 and GNU diff formats differ:
     # -@@ -0,0 +1 @@
     # +@@ -1,0 +1,1 @@
-    sed 's/    .*//;/^@@/d' out > k && mv k out
+    # Also, remove space after leading '+', since AIX 7.1 diff outputs a space.
+    sed 's/    .*//;/^@@/d;s/^+ /+/' out > k && mv k out
     cat <<\EOF > exp
 --- empty
 +++ in