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"
|
2022-04-18 20:05:49 +03:00
|
|
|
echo "moar" >"$WORKDIR/expected"
|
2022-04-18 09:41:40 +03:00
|
|
|
|
|
|
|
# Extract suggested PAGER value from moar --help
|
2024-10-27 11:59:13 +03:00
|
|
|
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
|