Work around BSD man calling pager when stdout is not a TTY

With BSD man, "PAGER=vim man man | cat" hangs because
[man](https://cgit.freebsd.org/src/tree/usr.bin/man/man.sh) wrongly
calls the pager even though stdout is not a terminal.

This hang manifests in places where we call apropos in a subshell,
such as in "complete -Ccar".

Let's work around this I guess. This should really be fixed upstream
because it's a problem in every app that wants to display man pages
but doesn't emulate a complete terminal.

Weirdly, the Apple derivative of man.sh uses WHATISPAGER instead
of MANPAGER.

Closes #10820
This commit is contained in:
Johannes Altmanninger 2024-10-30 04:33:01 +01:00
parent 31d7f197b1
commit ec939fb22f

View file

@ -36,7 +36,7 @@ if test $status -eq 0 -a (count $sysver) -eq 3
set age (path mtime -R -- $whatis)
end
MANPATH="$dir" apropos "$argv"
MANPATH="$dir" MANPAGER=cat WHATISPAGER=cat apropos "$argv"
if test $age -ge $max_age
test -d "$dir" || mkdir -m 700 -p $dir
@ -48,6 +48,6 @@ else
function __fish_apropos
# we only ever prefix match for completions. This also ensures results for bare apropos <TAB>
# (apropos '' gives no results, but apropos '^' lists all manpages)
apropos "$argv"
MANPAGER=cat WHATISPAGER=cat apropos "$argv"
end
end