]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: Reject broken 'join' program as seen in macOS, FreeBSD etc.
authorBruno Haible <bruno@clisp.org>
Thu, 11 Jan 2024 11:25:35 +0000 (12:25 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 11 Jan 2024 11:40:36 +0000 (12:40 +0100)
Reported by Avinash Sonawane <rootkea@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-01/msg00028.html>.

* gnulib-tool: Move the func_gnulib_dir and func_tmpdir invocations
ahead. If the 'join' program exists but does not handle missing fields,
bail out.

ChangeLog
gnulib-tool

index b032b5e088ef6a6da3e79752c044f48d7d9111cc..9825b0c8b98a6176bb6e92eae3e30d626fb8e57d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-11  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool: Reject broken 'join' program as seen in macOS, FreeBSD etc.
+       Reported by Avinash Sonawane <rootkea@gmail.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2024-01/msg00028.html>.
+       * gnulib-tool: Move the func_gnulib_dir and func_tmpdir invocations
+       ahead. If the 'join' program exists but does not handle missing fields,
+       bail out.
+
 2024-01-10  Bruno Haible  <bruno@clisp.org>
 
        jit/cache tests: Fix for powerpc64le CPUs.
index b909a81f7a1c270e0362286f2deb0088155826e2..9facfd2be7c1ed7e019a3bc3823f98204b6e5a20 100755 (executable)
@@ -894,15 +894,6 @@ func_hardlink ()
   }
 }
 
-# The 'join' program does not exist on all platforms.  Where it exists,
-# we can use it.  Where not, bail out.
-if (type join) >/dev/null 2>&1; then
-  :
-else
-  echo "$progname: 'join' program not found. Consider installing GNU coreutils." >&2
-  func_exit 1
-fi
-
 # Ensure an 'echo' command that
 #   1. does not interpret backslashes and
 #   2. does not print an error message "broken pipe" when writing into a pipe
@@ -1071,6 +1062,38 @@ if test "X$1" = "X--no-reexec"; then
   shift
 fi
 
+func_gnulib_dir
+func_tmpdir
+trap 'exit_status=$?
+      if test "$signal" != EXIT; then
+        echo "caught signal SIG$signal" >&2
+      fi
+      rm -rf "$tmp"
+      exit $exit_status' EXIT
+for signal in HUP INT QUIT PIPE TERM; do
+  trap '{ signal='$signal'; func_exit 1; }' $signal
+done
+signal=EXIT
+
+# The 'join' program does not exist on all platforms, and
+# on macOS 12.6, FreeBSD 14.0, NetBSD 9.3 it is buggy, see
+# <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232405>.
+# In these cases, bail out. Otherwise, we can use it.
+if (type join) >/dev/null 2>&1; then
+  echo a > "$tmp"/join-input-1
+  { echo; echo a; } > "$tmp"/join-input-2
+  if LC_ALL=C join "$tmp"/join-input-1 "$tmp"/join-input-2 | grep a >/dev/null \
+     && LC_ALL=C join "$tmp"/join-input-2 "$tmp"/join-input-1 | grep a >/dev/null; then
+    :
+  else
+    echo "$progname: 'join' program is buggy. Consider installing GNU coreutils." >&2
+    func_exit 1
+  fi
+else
+  echo "$progname: 'join' program not found. Consider installing GNU coreutils." >&2
+  func_exit 1
+fi
+
 # Unset CDPATH.  Otherwise, output from 'cd dir' can surprise callers.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
@@ -1690,19 +1713,6 @@ func_determine_path_separator
   esac
 }
 
-func_gnulib_dir
-func_tmpdir
-trap 'exit_status=$?
-      if test "$signal" != EXIT; then
-        echo "caught signal SIG$signal" >&2
-      fi
-      rm -rf "$tmp"
-      exit $exit_status' EXIT
-for signal in HUP INT QUIT PIPE TERM; do
-  trap '{ signal='$signal'; func_exit 1; }' $signal
-done
-signal=EXIT
-
 # Note: The 'eval' silences stderr output in dash.
 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
   # Zsh 4 and Bash 4 have associative arrays.