Fix manpath detection in tools/man.kak#5402
Fix manpath detection in tools/man.kak#5402silversquirl wants to merge 1 commit intomawww:masterfrom
Conversation
| -shell-script-candidates %{ | ||
| find /usr/share/man/ $(printf %s "${MANPATH}" | | ||
| sed 's/:/ /') -name '*.[1-8]*' | | ||
| : "${MANPATH:="$(manpath)"}" |
There was a problem hiding this comment.
I think this breaks the case where MANPATH is set but contains an empty component (which should be substituted with the "system default path").
$ env | grep MANPATH
MANPATH=/home/johannes/.local/share/man:
$ manpath
manpath: warning: $MANPATH set, appending /etc/man_db.conf
/home/johannes/.local/share/man:/home/johannes/.local/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/usr/lib/jvm/default/man
So I think we want to call manpath always,
or reimplement it by looking in $PATH
Either way, it looks like this patch would allow me to drop this explicitly-set $MANPATH which I just realized is already implied by $PATH (except in Kakoune's :man).
BTW, a completely different approach would be to use apropos ^ to compute these completions,
which should give the same results (it's shipped with mandoc man-db).
That's what fish shell uses; but it has gross workarounds for macOS.
We could try to get rid of those.
| : "${MANPATH:=/usr/share/man}" | ||
| set -f | ||
| IFS=: | ||
| find $MANPATH -name '*.[1-8]*' | |
There was a problem hiding this comment.
manpath will find the corresponding share/man directories for each entry in PATH.
where is this documented?
I can see the PATH behavior mentioned in FreeBSD man
but not in man-db man
The
manpathbinary is the preferred way to find the path for man pages with GNU man. This is relevant whenPATHcontains extra bin directories, butMANPATHis unset -manpathwill find the correspondingshare/mandirectories for each entry inPATH.