1

man <command> doesn't always point to the "right" (as in "given by which <command>"). Is there a way to make sure (or at least increase the chances that) I get docs that correspond to the command that will actually be executed?

EXAMPLE

With pack (a wads script) I get this:

$ which pack
.../dev/unix_scripts/pack
$ man pack                                                                                                                                  LIBPACK(3)

NAME
       libpack - support for connected components
...

Note that here .../dev/unix_scripts/pack doesn't actually have a man page, so I'd like the man to tell me it doesn't find it.

TRIED

If man took full paths to executable, I could do this:

$ which pack | man

This:

$ man 1 pack
No entry for pack in section 1 of the manual

but I'm not sure only looking in section 1 ("Executable programs or shell commands") is too restrictive.

General context

The underlying context is that I'm trying to write a (python) function that will get me some info on any "valid" (in the sense of which <command>) executable. A name is linked to a unique executable through which. How do I get docs-like information about that executable?

I (post my question on stackoverflow)[https://stackoverflow.com/questions/73814043/universal-help-for-terminal-commands], which was banished as "not a software question", so I reduced the question and posted it here.

1
  • Man operates on files in MANPATH. (Read man man.) Distros often package symlinks to manpages, effectively creating "aliases". If you don't want the specific manpage to be displayed when you supply a specific argument to man(1), you will need to organize (move/remove) manpages or symlinks to manpages yourself, including configuring your package manager to not undo your changes on next update. Sep 23, 2022 at 9:09

1 Answer 1

0

man <command> is inaccurate — distributions generally include more than man pages just for commands. This is what you’re running into here: man pack is showing you the documentation for a library.

You mention that you tried man 1 pack, but that you’re wondering whether that is too restrictive; it seems to me that if you’re only interested in commands, then that is a good approach. You may need to also look in section 8 in some cases, but for non-administrative commands, man 1 foo will match a command most of the time (the exception I can think of is man 1 intro).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .