I'm puzzled by how the path used for finding man
pages is set. The "right thing" seems to happen magically. For example, if change my PATH from
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin
to
/usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin
the path searched for man
pages (according to man --path
) changes from
/usr/share/man:/usr/local/share/man:/opt/X11/share/man:/usr/local/git/share/man:/usr/texbin/man
to
/usr/local/git/share/man:/usr/share/man:/usr/local/share/man:/opt/X11/share/man:/usr/texbin/man
Somehow, the version of Git that I'm "overriding" the default Git with, is having it's documentation correctly found before any documentation for any built in Git. How is that happening?
Best Answer
The path for man is determined either by the env variable MANPATH or by constructing a MANPATH from PATH and /etc/manpath.config
The reason your local git man pages are being picked up first is because the MANPATH generated is in the same order present in PATH, so your
/usr/local/git/bin
at the beginning of PATH means that manpath will (if it can find it) place the matching man path at the beginning of MANPATH (in this case,/usr/local/git/share/man
).Paths that are earlier in your MANPATH are searched first and man(1) will display the first match.
For more information on this see manpath(1) and for the configuration file see manpath(5)