batman: Fix BAT_PAGER causing infinite recursion

Rather than replacing `BAT_PAGER` with `MANPAGER` every time batman is
used, only replace it when batman is called directly (and not used as
the MANPAGER).
This commit is contained in:
Ethan P. 2024-02-12 01:28:34 -08:00
parent 5011f0709e
commit 205e9c40e1
No known key found for this signature in database
GPG Key ID: 1BA2A0CC7C22B854

View File

@ -9,7 +9,6 @@
SELF_NC="${BASH_SOURCE:-$0}" SELF_NC="${BASH_SOURCE:-$0}"
SELF="$(cd "$(dirname "${SELF_NC}")" && cd "$(dirname "$(readlink "${SELF_NC}" || echo ".")")" && pwd)/$(basename "$(readlink "${SELF_NC}" || echo "${SELF_NC}")")" SELF="$(cd "$(dirname "${SELF_NC}")" && cd "$(dirname "$(readlink "${SELF_NC}" || echo ".")")" && pwd)/$(basename "$(readlink "${SELF_NC}" || echo "${SELF_NC}")")"
LIB="$(cd "$(dirname "${SELF_NC}")" && cd "$(dirname "$(readlink "${SELF_NC}" || echo ".")")/../lib" && pwd)" LIB="$(cd "$(dirname "${SELF_NC}")" && cd "$(dirname "$(readlink "${SELF_NC}" || echo ".")")/../lib" && pwd)"
if [[ -n "${MANPAGER}" ]]; then BAT_PAGER="$MANPAGER"; fi
source "${LIB}/constants.sh" source "${LIB}/constants.sh"
source "${LIB}/pager.sh" source "${LIB}/pager.sh"
source "${LIB}/print.sh" source "${LIB}/print.sh"
@ -65,6 +64,7 @@ if [[ "${BATMAN_IS_BEING_MANPAGER:-}" = "yes" ]]; then
fi fi
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
if [[ -n "${MANPAGER}" ]]; then BAT_PAGER="$MANPAGER"; fi
export MANPAGER="env BATMAN_IS_BEING_MANPAGER=yes bash $(printf "%q " "$SELF" "${FORWARDED_ARGS[@]}")" export MANPAGER="env BATMAN_IS_BEING_MANPAGER=yes bash $(printf "%q " "$SELF" "${FORWARDED_ARGS[@]}")"
export MANROFFOPT='-c' export MANROFFOPT='-c'