From: Nick Bowler Date: Tue, 24 Jan 2023 04:21:42 +0000 (-0500) Subject: Use AC_PROG_AWK and $AWK in DX_LINGUAS. X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/commitdiff_plain/70c84546fa5ecaba26e4ed021b292a5580f304f0 Use AC_PROG_AWK and $AWK in DX_LINGUAS. The awk script used internally by this macro does not work on traditional awk, such as old Solaris /bin/awk. Use $AWK to get a better awk. To avoid similar problems in the future, arrange for tests to be run with a busted "awk" command in PATH, so only $AWK will work at all. --- diff --git a/m4/linguas.m4 b/m4/linguas.m4 index fce4e0c..f1cc4b1 100644 --- a/m4/linguas.m4 +++ b/m4/linguas.m4 @@ -1,4 +1,4 @@ -dnl Copyright © 2011, 2021-2022 Nick Bowler +dnl Copyright © 2011, 2021-2023 Nick Bowler dnl dnl Computes the set of .po and .mo files based on the LINGUAS environment dnl variable. The variable POFILES is set to the complete list of .po files, @@ -13,12 +13,13 @@ dnl There is NO WARRANTY, to the extent permitted by law. AC_DEFUN([DX_LINGUAS], [AC_REQUIRE([AM_GNU_GETTEXT])dnl AC_REQUIRE([DX_PROG_JOIN])dnl +AC_REQUIRE([AC_PROG_AWK])dnl POFILES= MOFILES= if test -f "$srcdir/po/LINGUAS"; then - awk '{ sub(/#.*$/, "") + $AWK '{ sub(/#.*$/, "") for (i = 1; i <= NF; i++) { print $(i) } diff --git a/t/bork/awk b/t/bork/awk new file mode 100755 index 0000000..8b3573c --- /dev/null +++ b/t/bork/awk @@ -0,0 +1,4 @@ +#!/bin/sh + +echo 'dummy dysfunctional awk' 1>&2 +false diff --git a/testsuite.at b/testsuite.at index 9c36c2f..badb6de 100644 --- a/testsuite.at +++ b/testsuite.at @@ -23,6 +23,16 @@ m4_divert_pop([PREPARE_TESTS]) m4_define([TEST_CONFIGURE_AC], [AT_KEYWORDS([autoconf m4])dnl AT_DATA([configure.ac], [[AC_INIT([test], [0]) + +# Install t/bork into the path, which contains a non-functional +# dummy "awk" command to catch direct "awk" usage (as opposed to +# using AC_PROG_AWK and $AWK). Then work around direct awk usage +# in LT_INIT to avoid the dummy. +test_orig_PATH=$PATH +PATH=$at_srcdir/t/bork:$PATH +m4@&t@_ifdef([LT_INIT], [m4@&t@_define([LT_INIT], +[m4@&t@_pushdef([awk], [$AWK])]m4@&t@_defn([LT_INIT])[m4@&t@_popdef([awk])])]) + ]$1[ AC_OUTPUT ]]) @@ -49,7 +59,8 @@ AT_CHECK([autoreconf -I "$srcdir/m4"], [0], [], [stderr])]) m4_define([TEST_CONFIGURE], [AT_KEYWORDS([configure])dnl AT_CHECK([export CC CONFIG_SHELL=$TEST_SHELL $TEST_SHELL m4_default([$2], -[./configure]) --quiet CONFIG_SHELL=$TEST_SHELL $1])]) +[./configure]) --quiet CONFIG_SHELL="$TEST_SHELL" \ + at_srcdir="$srcdir" AWK="$AWK" $1])]) m4_include([tests/macros.at]) m4_include([tests/snippets.at])