From ec939fb22fcd6073896a6ff7ebc2caac9089dfc2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 30 Oct 2024 04:33:01 +0100 Subject: [PATCH] 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 --- share/functions/__fish_apropos.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_apropos.fish b/share/functions/__fish_apropos.fish index d665f8063..8bf412e98 100644 --- a/share/functions/__fish_apropos.fish +++ b/share/functions/__fish_apropos.fish @@ -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 # (apropos '' gives no results, but apropos '^' lists all manpages) - apropos "$argv" + MANPAGER=cat WHATISPAGER=cat apropos "$argv" end end