]> git.draconx.ca Git - dxcommon.git/commitdiff
Use AC_PROG_AWK and $AWK in DX_LINGUAS.
authorNick Bowler <nbowler@draconx.ca>
Tue, 24 Jan 2023 04:21:42 +0000 (23:21 -0500)
committerNick Bowler <nbowler@draconx.ca>
Tue, 24 Jan 2023 04:21:42 +0000 (23:21 -0500)
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.

m4/linguas.m4
t/bork/awk [new file with mode: 0755]
testsuite.at

index fce4e0c07c919569360b3ca7ebdfd5cbef2c0d7a..f1cc4b18585db578d972c517a3a6c81afa203578 100644 (file)
@@ -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 (executable)
index 0000000..8b3573c
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo 'dummy dysfunctional awk' 1>&2
+false
index 9c36c2f330a59465b89d85813736ee91c4f7d7bc..badb6de9315718b8d215d5f5b3685664bbc66ff9 100644 (file)
@@ -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])