1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-25 13:05:08 -07:00
libsodium/test/default/nacl-test-wrapper.sh
Jim Patterson 1fd6a4bfc2 Replace which with command for portability (#542)
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.
2017-05-19 14:51:56 +02:00

32 lines
771 B
Bash
Executable File

#! /bin/sh
if [ -z "$NACL_SDK_ROOT" ]; then
echo "The following variable needs to be set:
\$NACL_SDK_ROOT=$NACL_SDK_ROOT" >&2
exit 1
fi
if [ -z "$PNACL_FINALIZE" -o -z "$PNACL_TRANSLATE" ]; then
exe="$1"
else
exe="$1.nexe"
if [ ! -f "$exe" ]; then
$PNACL_FINALIZE "$1" -o "$1.final"
$PNACL_TRANSLATE -arch $(uname -m) "$1.final" -o "$exe"
fi
fi
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)
if [ -z "$SEL_LDR" ]; then
echo "Couldn't find sel_ldr.py under $NACL_SDK_ROOT" >&2
exit 1
fi
exec python "$SEL_LDR" "$exe"