mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Fix man function for NetBSD
NetBSD's man is unusual in that it doesn't understand an empty $MANPATH component as "the system man path", and doesn't have a `manpath` or `man --path`. It has a `-m` option that would be useful, but other mans also have a `-m` option that isn't, so detecting it is tough. It does have a `-p` option that almost does what one would want here, so we hack around it to make things work. Fixes #5657. [ci skip]
This commit is contained in:
parent
f037b0f30f
commit
5814b1b8e2
1 changed files with 12 additions and 0 deletions
|
@ -12,6 +12,18 @@ function man --description "Format and display the on-line manual pages"
|
|||
set -l manpath
|
||||
if set -q MANPATH
|
||||
set manpath $MANPATH
|
||||
else if set -l p (command man -p 2>/dev/null)
|
||||
# NetBSD's man uses "-p" to print the path.
|
||||
# FreeBSD's man also has a "-p" option, but that requires an argument.
|
||||
# Other mans (men?) don't seem to have it.
|
||||
#
|
||||
# Unfortunately NetBSD prints things like "/usr/share/man/man1",
|
||||
# while not allowing them as $MANPATH components.
|
||||
# What it needs is just "/usr/share/man".
|
||||
#
|
||||
# So we strip the last component.
|
||||
# This leaves a few wrong directories, but that should be harmless.
|
||||
set manpath (string replace -r '[^/]+$' '' $p)
|
||||
else
|
||||
set manpath ''
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue