bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH] test-framework-sh: work around AIX 7.2 diff bugs
Date: Sat, 14 Jan 2023 16:49:36 -0800	[thread overview]
Message-ID: <20230115004936.112948-1-eggert@cs.ucla.edu> (raw)

* tests/init.sh (compare_dev_null_): Run diff in the C locale.
AIX 7.2 diff messes up in UTF-8 locales; for example,
‘printf '\360\220\200\200\n' | diff - /dev/null’ incorrectly
outputs nothing and exits with status 0 when LC_ALL=en_US.UTF-8.
---
 ChangeLog     | 8 ++++++++
 tests/init.sh | 7 ++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fb467a3c14..0900c54c1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-01-14  Paul Eggert  <eggert@cs.ucla.edu>
+
+	test-framework-sh: work around AIX 7.2 diff bugs
+	* tests/init.sh (compare_dev_null_): Run diff in the C locale.
+	AIX 7.2 diff messes up in UTF-8 locales; for example,
+	‘printf '\360\220\200\200\n' | diff - /dev/null’ incorrectly
+	outputs nothing and exits with status 0 when LC_ALL=en_US.UTF-8.
+
 2023-01-14  Bruno Haible  <bruno@clisp.org>
 
 	error, verror tests: Fix link error when the package uses libintl.
diff --git a/tests/init.sh b/tests/init.sh
index 6c09392867..0494097e9f 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -646,18 +646,19 @@ compare_dev_null_ ()
 
 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` &&
+    diff_out_=`exec 2>/dev/null
+      LC_ALL=C 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_ "$@"; }
+    compare_ () { LC_ALL=C diff $diff_opt_ "$@"; }
   else
     compare_ ()
     {
       # If no differences were found, AIX and HP-UX 'diff' produce output
       # like "No differences encountered".  Hide this output.
-      diff $diff_opt_ "$@" > diff.out
+      LC_ALL=C 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
-- 
2.37.2



                 reply	other threads:[~2023-01-15  0:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230115004936.112948-1-eggert@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).