From 8fd8e66294d6eaf47984de6bf72682bf048d76cd Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 9 Jan 2024 23:07:41 -0500 Subject: [PATCH] autogen.sh: successfully detect if the autoreconf program is installed The "which" utility is not guaranteed to be installed either, and if it is, its behavior is not portable either. This means that when autoreconf is installed, the `which` check will report a fatal error because the which tool did not exist and the shell returned a nonzero status when attempting to fork+exec. If it did exist, it might not be an implementation of `which` that returns nonzero when commands do not exist. The general scripting suggestion is to use the "command -v" shell builtin; this is required to exist in all POSIX 2008 compliant shells, and is thus guaranteed to work everywhere. For some in-depth discussions on the topic, see: - https://mywiki.wooledge.org/BashFAQ/081 - https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then/85250#85250 Examples of open-source shells likely to be installed as /bin/sh on Linux, which implement the 15-year-old standard: ash, bash, busybox, dash, ksh, mksh and zsh. Signed-off-by: Eli Schwartz --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index af7d03c30..3745acde1 100755 --- a/autogen.sh +++ b/autogen.sh @@ -36,7 +36,7 @@ cd "$srcdir" mkdir -p m4 -AUTORECONF=`which autoreconf` +AUTORECONF=`command -v autoreconf` if test -z $AUTORECONF; then echo "*** No autoreconf found ***" exit 1