1
1
mirror of https://github.com/wader/fq.git synced 2024-11-29 12:14:17 +03:00
fq/pkg/cli/test_exp.sh
Sam James 08df7f45c8
pkg/cli/test_exp.sh: use command -v
`which` is non-portable and not part of POSIX, but we can use `command -v`
for the same effect.

Debian [0] and Gentoo [1] are both trying to drop which from their base system.

[0] https://lwn.net/Articles/874049/
[1] https://bugs.gentoo.org/646588

Signed-off-by: Sam James <sam@gentoo.org>
2024-02-27 23:04:10 +00:00

22 lines
426 B
Bash
Executable File

#!/bin/sh
set -eu
FQ="$1"
shift
if command -v expect >/dev/null 2>&1; then
TEMPDIR=$(mktemp -d)
cp "$FQ" "${TEMPDIR}/fq"
PATH="${TEMPDIR}:${PATH}" expect "$1" >"${TEMPDIR}/fq.log" && FAIL=0 || FAIL=1
if [ $FAIL = "1" ]; then
cat "${TEMPDIR}/fq.log"
fi
rm -rf "${TEMPDIR}"
if [ $FAIL = "1" ]; then
exit 1
fi
echo "$0"
else
echo "$0: skip as expect is not installed"
fi