9

On my linux system, I can do "man git log" (note the space), and this will show me the manpage for git-log(1) (with a dash), as expected.

On my MacOSX machine, "man git log" only shows the manual page for git(1).

How does the linux man know that the two arguments "git" and "log" should be combined to find the "git-log" manpage? How would I get the same result in OSX?

  • what version of git do you have in your mac? and what version in your "linux system"? – KurzedMetal Sep 23 '15 at 18:45
  • git-log is not the appropriate command in osx, whereas git log is. It's a good question, my guess is git-log is a concatenation or something to let terminal know to look up both items, because man will execute the first argument and ignore the latter. – nykc Sep 23 '15 at 19:40
  • @KurzedMetal: 2.5.1 on OSX via MacPorts, 2.5.3 on Debian Sid – John de Largentaye Sep 23 '15 at 22:15
  • 2
    @nykc: actually, the `git` command is really just a dispatcher to a whole collection of subcommands as executables usually located in some out-of-the-way directory. On Deb Sid, they're in /usr/lib/git-core/. On OSX via MacPorts they're in /opt/local/libexec/git-core/ You can run them from there directly! This setup is why their manpages list them with dashes. – John de Largentaye Sep 23 '15 at 22:19
  • @JohndeLargentaye I wasn't sure the reason but was interested in the answer. Thanks for clarifying – nykc Sep 23 '15 at 23:43

1 Answers1

12

This is a feature of the particular implementation of man used on many Linux systems. Referring to the documentation (for man), it is mentioned in the description of the --no-subpages option:

--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 or an underscore. This supports the common pattern 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 subcommands themselves.

Other implementations of man can do different things. For instance (not well documented, but there if you study it), a quick check for man git status on OSX El Capitan shows it tries to find a manual page for status. However, man git-status gives a manual page.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • 1
    Thanks! And I see it was added [mid-2009 by Colin Watson of Debian](http://git.savannah.gnu.org/cgit/man-db.git/commit/?id=7de45db026166ea55f9b7c240928ef0de0245a3f), which would explain why it was there for what felt like forever, but old versions of RedHat didn't have it. – John de Largentaye Sep 23 '15 at 22:41
  • Consequently, one may not enjoy the same behavior on Mac OS X, which does not have that particular man implementation, at least not out of the box, is that so? – Dave Land Feb 24 '16 at 21:10