Skip to content

Commit

Permalink
Replace which with command for portability (jedisct1#542)
Browse files Browse the repository at this point in the history
The `which` command is not part of the posix standard and not available
in some environments.  The `command` command is part of the posix
standard and well supported.

See https://unix.stackexchange.com/q/85249 for a discussion about the
use of `command` instead of `which`.

If a system had `libtool` but not `which`, the build process would issue
an erroneous error stating:

    libtool is required, but wasn't found on this system

Switching to `command` corrects this problem.
  • Loading branch information
JimPatterson authored and jedisct1 committed May 19, 2017
1 parent 00212b2 commit 1fd6a4b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
17 changes: 11 additions & 6 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ else
LIBTOOLIZE='libtoolize'
fi

if [ ! -x "`which $LIBTOOLIZE 2>/dev/null`" ] ; then
command -v command >/dev/null 2>&1 || {
echo "command is required, but wasn't found on this system"
exit 1
}

command -v $LIBTOOLIZE >/dev/null 2>&1 || {
echo "libtool is required, but wasn't found on this system"
exit 1
fi
}

if [ ! -x "`which autoconf 2>/dev/null`" ] ; then
command -v autoconf >/dev/null 2>&1 || {
echo "autoconf is required, but wasn't found on this system"
exit 1
fi
}

if [ ! -x "`which automake 2>/dev/null`" ] ; then
command -v automake >/dev/null 2>&1 || {
echo "automake is required, but wasn't found on this system"
exit 1
fi
}

if autoreconf --version > /dev/null 2>&1 ; then
exec autoreconf -ivf
Expand Down
5 changes: 4 additions & 1 deletion test/default/nacl-test-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ else
fi
fi

which python >/dev/null 2>&1 || \
command -v command >/dev/null 2>&1 || \
{ echo "command is required, but wasn't found on this system"; exit 1; }

command -v python >/dev/null 2>&1 || \
{ echo >&2 "Python not found. Aborting."; exit 1; }

SEL_LDR=$(find "$NACL_SDK_ROOT" -name sel_ldr.py | head -n 1)
Expand Down

0 comments on commit 1fd6a4b

Please sign in to comment.