Skip to content

Commit 58889b9

Browse files
committed
fix(man): work around the case both "manpath" and "man -w" are missing
There were systems where both "manpath" and "man -w" fail. In such systems, the manpaths should be primarily determined by the shell variable MANPATH.
1 parent f966e62 commit 58889b9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

completions/man

+11-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ _man()
5858
fi
5959

6060
local manpath=$(manpath 2>/dev/null || command man -w 2>/dev/null)
61-
[[ -z $manpath ]] && manpath="/usr/share/man:/usr/local/share/man"
61+
if [[ -z $manpath ]]; then
62+
# Note: Both "manpath" and "man -w" may be unavailable, in
63+
# which case we determine the man paths based on the
64+
# environment variable MANPATH.
65+
manpath=:${MANPATH-}:
66+
# Note: An empty path (represented by two consecutive colons
67+
# or a preceding/trailing colon) represents the system man
68+
# paths.
69+
manpath=${manpath//::/':/usr/share/man:/usr/local/share/man:'}
70+
manpath=${manpath:1:-1}
71+
fi
6272

6373
# determine manual section to search
6474
local sect

0 commit comments

Comments
 (0)