diff --git a/share/completions/man.fish b/share/completions/man.fish index 3b765a101..35aec2de6 100644 --- a/share/completions/man.fish +++ b/share/completions/man.fish @@ -38,7 +38,7 @@ complete -c man -n 'string match -q -- "*/*" (commandline -t | string collect)' if command -q man # We have a conditionally-defined man function, # so we need to check for existence here. - if echo | MANPAGER=cat command man -l - &>/dev/null + if echo | __fish_without_manpager command man -l - &>/dev/null complete -c man -s l -l local-file -d "Local file" -r end end diff --git a/share/functions/__fish_apropos.fish b/share/functions/__fish_apropos.fish index 4cb02b5c5..a667d482a 100644 --- a/share/functions/__fish_apropos.fish +++ b/share/functions/__fish_apropos.fish @@ -5,9 +5,7 @@ if not type -q apropos exit end -# Check for macOS Catalina or above. if test (__fish_uname) = Darwin - and test (string match -r "^\d+" "$(uname -r)") -ge 19 and test -x /usr/libexec/makewhatis set -l dir @@ -18,6 +16,11 @@ if test (__fish_uname) = Darwin end function __fish_apropos -V dir + if test "$(command -v apropos)" != /usr/bin/apropos + __fish_without_manpager apropos "$argv" + return + end + # macOS 10.15 "Catalina" has a read only filesystem where the whatis database should be. # The whatis database is non-existent, so apropos tries (and fails) to create it every time, # which can take seconds. @@ -34,17 +37,19 @@ if test (__fish_uname) = Darwin set age (path mtime -R -- $whatis) end - MANPATH="$dir" MANPAGER=cat WHATISPAGER=cat apropos "$argv" + MANPATH="$dir" __fish_without_manpager apropos "$argv" if test $age -ge $max_age test -d "$dir" || mkdir -m 700 -p $dir - /bin/sh -c '( "$@" ) >/dev/null 2>&1 /dev/null 2>&1 # (apropos '' gives no results, but apropos '^' lists all manpages) - MANPAGER=cat WHATISPAGER=cat apropos "$argv" + __fish_without_manpager apropos "$argv" end end diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish index e3b3d8ef7..a9575c93d 100644 --- a/share/functions/__fish_print_help.fish +++ b/share/functions/__fish_print_help.fish @@ -10,7 +10,7 @@ function __fish_print_help --description "Print help for the specified fish func end set -l args -l (path filter -- $man1/$item.1 $man1/$item.1.gz)[1] # Work around macOS/FreeBSD man not supporting -l yet (only mandoc really needs it). - if not MANPAGER=cat WHATISPAGER=cat command man -l $args[2] &>/dev/null + if not __fish_without_manpager command man -l $args[2] &>/dev/null set -e args[1] end command man $args diff --git a/share/functions/__fish_without_manpager.fish b/share/functions/__fish_without_manpager.fish new file mode 100644 index 000000000..df3ed30eb --- /dev/null +++ b/share/functions/__fish_without_manpager.fish @@ -0,0 +1,7 @@ +function __fish_without_manpager + MANPAGER=cat WHATISPAGER=cat if test "$argv[1]" = command + command $argv[2..] + else + $argv + end +end