From: Bruno Haible Date: Thu, 11 Jan 2024 11:25:35 +0000 (+0100) Subject: gnulib-tool: Reject broken 'join' program as seen in macOS, FreeBSD etc. X-Git-Tag: v1.0~526 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=0e9339b3d1cc818ad140a181545668fb870b3830;p=gnulib.git gnulib-tool: Reject broken 'join' program as seen in macOS, FreeBSD etc. Reported by Avinash Sonawane in . * 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. --- diff --git a/ChangeLog b/ChangeLog index b032b5e088..9825b0c8b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-01-11 Bruno Haible + + gnulib-tool: Reject broken 'join' program as seen in macOS, FreeBSD etc. + Reported by Avinash Sonawane in + . + * 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 jit/cache tests: Fix for powerpc64le CPUs. diff --git a/gnulib-tool b/gnulib-tool index b909a81f7a..9facfd2be7 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -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 +# . +# 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.