Skip to content

Commit

Permalink
autogen.sh: successfully detect if the autoreconf program is installed
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
eli-schwartz authored and dvrogozh committed Jan 24, 2024
1 parent b8c7eed commit 8fd8e66
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8fd8e66

Please sign in to comment.