1
1
mirror of https://github.com/walles/moar.git synced 2024-11-22 11:45:50 +03:00
moar/scripts/test-path-help.sh

30 lines
745 B
Bash
Raw Normal View History

2022-04-18 09:41:40 +03:00
#!/bin/bash
# Verify the PAGER= suggestion is correct in "moar --help" output.
#
# Ref: https://github.com/walles/moar/issues/88
set -e -o pipefail
MOAR="$(realpath "$1")"
if ! [ -x "$MOAR" ]; then
echo ERROR: Not executable: "$MOAR"
exit 1
fi
echo Testing PAGER= suggestion in moar --help output...
2022-04-18 20:12:25 +03:00
WORKDIR="$(mktemp -d -t moar-path-help-test.XXXXXXXX)"
2022-04-18 09:41:40 +03:00
# Put a symlink to $MOAR first in the $PATH
ln -s "$MOAR" "$WORKDIR/moar"
echo "moar" >"$WORKDIR/expected"
2022-04-18 09:41:40 +03:00
# Extract suggested PAGER value from moar --help
unset PAGER
PATH="$WORKDIR" PAGER="" moar --help | grep "PAGER" | grep -v "is empty" | sed -E 's/.*PAGER[= ]//' >"$WORKDIR/actual"
2022-04-18 09:41:40 +03:00
# Ensure it matches the symlink we have in $PATH
cd "$WORKDIR"
diff -u actual expected