Man 命令意外地接受参数 ``git diff``

Man 命令意外地接受参数 ``git diff``

今天,我不小心输入了man git diff应该不会产生任何结果的命令,因为根据手册,它应该被解释为页面差异在部分git。然而,页面git-diff(1)确实显示了。怎么会这样?(使用 Ubuntu Lucid 中包含的 man 2.5.7)

答案1

Ubuntu 上的 man(1) 说:

--no-subpages
              By default, man will try to interpret pairs of manual page names given on the command line as
              equivalent to a single manual page name containing a hyphen.  This supports the  common  pat-
              tern  of  programs  that  implement  a number of subcommands, allowing them to provide manual
              pages for each that can be accessed using similar syntax as would be used to invoke the  sub-
              commands themselves.  For example:

                $ man -aw git diff
                /usr/share/man/man1/git-diff.1.gz

              To disable this behaviour, use the --no-subpages option.

                $ man -aw --no-subpages git diff
                /usr/share/man/man1/git.1.gz
                /usr/share/man/man3/Git.3pm.gz
                /usr/share/man/man1/diff.1.gz

答案2

Git 可能有一个指向的diff引用。gitgit-diff

相关内容