如何让 `MANPATH=~/.nmap/doc man 1 nmap` 寻找 nmap.1?

How to make `MANPATH=~/.nmap/doc man 1 nmap` look for nmap.1?

我最近决定,因为我经常试验最新版本的 nmap,最好将其 SVN 签出保留在 ~/.nmap 中而不安装,而只 运行 svn up; make 使其保持最新状态。我将 ~/.nmap 添加到 $PATH,然后才意识到使用此设置,我不能再 运行 man nmap。我阅读了 $MANPATH 并意识到这似乎对我不起作用:

[14:51:28][~/.nmap]$ manpath                                          
manpath: warning: $MANPATH set, prepending /etc/man_db.conf
/home/d/virtualenv/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/usr/man:/home/d/.nmap/docs/man-xlate/:/home/d/.nmap/docs
[14:51:32][~/.nmap]$ strace  man 1 nmap 2>&1 | egrep 'nmap.1|write'
stat("/home/d/.nmap/docs/zenmap.1", {st_mode=S_IFREG|0664, st_size=5943, ...}) = 0
stat("/home/d/.nmap/docs/nmap.1", {st_mode=S_IFREG|0664, st_size=183621, ...}) = 0
access("/usr/share/man/man1/nmap.1.gz", R_OK) = -1 ENOENT (No such file or directory)
write(2, "No manual entry for nmap in sect"..., 38No manual entry for nmap in section 1

为什么会这样,我该如何解决?我注意到 man 也在 ~/.nmap/docs 中查找名为 index.db 的文件,但找不到它,也许这是一个线索?

问题是 docs 目录没有 man 需要的目录结构(nmap.1 应该在 man1 子目录中),与使用 -M 选项时相同:

    -M path, --manpath=path
          Specify an alternate manpath to use.  By default,  man  uses
          manpath  derived code to determine the path to search.  This
          option  overrides  the  $MANPATH  environment  variable  and
          causes option -m to be ignored.

          A  path  specified as a manpath must be the root of a manual
          page hierarchy structured into sections as described in  the
          man-db  manual  (under  "The  manual page system").  To view
          manual pages outside such hierarchies, see the -l option.

使用 make install 时,联机帮助页会安装到正确的类别子目录中。所以直接 MANPATH 指向 docs 目录是行不通的。