aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb@gnu.org>2024-09-17 20:41:31 -0500
committerJacob Bachmeyer <jcb@gnu.org>2024-09-18 20:31:43 -0500
commit196e2199c1a4d6179a5191e4bb9dfde45c41d404 (patch)
treea0b3ffb115b4f76e96f16a0d0a6ba3de71dce151
parent20306d7feb8b7e67485118aa56ba7658de6ccfc5 (diff)
downloaddejagnu-196e2199c1a4d6179a5191e4bb9dfde45c41d404.zip
dejagnu-196e2199c1a4d6179a5191e4bb9dfde45c41d404.tar.gz
dejagnu-196e2199c1a4d6179a5191e4bb9dfde45c41d404.tar.bz2
Improve search for POSIX awk in dejagnu auxiliary launcher
-rw-r--r--ChangeLog5
-rwxr-xr-xdejagnu41
2 files changed, 30 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 160a280..05194b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2024-09-17 Jacob Bachmeyer <jcb@gnu.org>
+ * dejagnu: Improve search for Awk interpreter using POSIX
+ command(1) utility to search paths. Also use POSIX getconf(1) to
+ obtain a standard system PATH that should contain POSIX versions
+ of various utilities; this enables finding POSIX Awk on Solaris 10.
+
* dejagnu: Quote "$verbose" when incrementing verbosity counter to
resolve shellcheck warning.
* runtest: Likewise.
diff --git a/dejagnu b/dejagnu
index 33ccf6f..3b0a409 100755
--- a/dejagnu
+++ b/dejagnu
@@ -64,6 +64,15 @@
Variants='gawk awk tcl exp bash sh'
readonly Variants
+# POSIX defines a getconf(1) command; here it returns a default PATH
+SysPATH=`getconf PATH`
+# make sure that the "system PATH" mentions at least one directory
+case $SysPATH in
+ */*) ;; # good
+ *) SysPATH=$PATH ;; # otherwise copy the user PATH
+esac
+readonly SysPATH
+
## Recognize options
# For testing and development
@@ -225,33 +234,33 @@ fi
## Find interpreters.
# Awk and GNU awk
+have_awk=false
if test -n "$AWK" ; then
awkbin="$AWK"
-elif test -x "${bindir}/awk" ; then
- awkbin="${bindir}/awk"
+ if command -v "$awkbin" > /dev/null 2>&1 ; then
+ have_awk=true
+ fi
else
- # find what might be a usable awk
+ # find a usable awk
# on Solaris 10, POSIX awk is in /usr/xpg4/bin
- for awktest in mawk /usr/xpg4/bin/awk nawk awk ; do
- if command -v "$awktest" > /dev/null 2>&1 ; then
- awkbin=$awktest
- break;
- fi
+ for testPATH in "$SysPATH" "$PATH" ; do
+ for awktest in mawk awk nawk ; do
+ if PATH=$testPATH command -v "$awktest" > /dev/null 2>&1 ; then
+ awkbin=`PATH=$testPATH command -v "$awktest"`
+ # The non-POSIX awk in /usr/bin on Solaris 10 fails this test
+ if echo | "$awkbin" '1 && 1 {exit 0}' > /dev/null 2>&1 ; then
+ have_awk=true
+ break 2
+ fi
+ fi
+ done
done
fi
if test -n "$GAWK" ; then
gawkbin="$GAWK"
-elif test -x "${bindir}/gawk" ; then
- gawkbin="${bindir}/gawk"
else
gawkbin=gawk
fi
-# The non-POSIX awk in /usr/bin on Solaris 10 fails this test
-if echo | "$awkbin" '1 && 1 {exit 0}' > /dev/null 2>&1 ; then
- have_awk=true
-else
- have_awk=false
-fi
if command -v "$gawkbin" > /dev/null 2>&1 ; then
have_gawk=true
else