6

I was just wondering why echo $MANPATH does not work (on my system (Debian Jessie x86_64 GNU/Linux 3.16.0-4-amd64)). The manpath command alone works well:

user@host:~$ manpath
/usr/local/man:/usr/local/share/man:/usr/share/man

/etc/manpath.config - exists and contains uncommented lines, according to the ones listed by manpath.

The manpath man page says:

If $MANPATH is set, manpath will simply display its contents ...

So, why does manpath work and echo $MANPATH doesn't?

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
jonasjacek
  • 69
  • 1
  • 6

2 Answers2

6

From my man manpath (Ubuntu 16.10 - as you didn't mention your system details):

If $MANPATH is set, manpath displays its value rather than determining it on the fly.

So $MANPATH is more of an override to the otherwise default configuration held by /etc/manpath.config.

Note also:

DESCRIPTION

If $MANPATH is set, manpath will simply display its contents and issue a warning. If not, manpath will determine a suitable manual page hierarchy search path and display the results.

ziesemer
  • 251
  • 2
  • 10
2

Cause that is all about the variable $MANPATH existence: To be overwritten if a customized manpath is needed.

Quoting Debian Lenny manpages:

DESCRIPTION

If $MANPATH is set, manpath will simply display its contents and issue a warning. If not, manpath will determine a suitable manual page hierarchy search path and display the results.

The colon-delimited path is determined using information gained from the man-db configuration file - (/etc/manpath.config) and the user’s environment.

When the manual page say "If $MANPATH is set," the meaning is "if this variable is set by the user or script..." or "if this variable is empty, use the defaults located at manpath.config".

Take a time and crawl through the /etc/manpath.config file to learn how all manpages path are structured.

Related Stuff:

Some links about manipulating $MANPATH or creating custom man pages path.