mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-23 21:31:14 -03:00
Extract workaround for calling man/apropos without manpager
See ec939fb22f (Work around BSD man calling pager when stdout is
not a TTY, 2024-10-30).
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -34,17 +34,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 &' -- /usr/libexec/makewhatis -o "$whatis" (/usr/bin/manpath | string split : | xargs realpath)
|
||||
/bin/sh -c '( "$@" ) >/dev/null 2>&1 </dev/null &' -- \
|
||||
/usr/libexec/makewhatis -o "$whatis" \
|
||||
(/usr/bin/manpath | string split : | xargs realpath)
|
||||
end
|
||||
end
|
||||
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)
|
||||
MANPAGER=cat WHATISPAGER=cat apropos "$argv"
|
||||
__fish_without_manpager apropos "$argv"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
8
share/functions/__fish_without_manpager.fish
Normal file
8
share/functions/__fish_without_manpager.fish
Normal file
@@ -0,0 +1,8 @@
|
||||
# localization: skip(private)
|
||||
function __fish_without_manpager
|
||||
MANPAGER=cat WHATISPAGER=cat if test "$argv[1]" = command
|
||||
command $argv[2..]
|
||||
else
|
||||
$argv
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user