Bug 249297 - man: manual pages in non-default sections not found
Summary: man: manual pages in non-default sections not found
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-14 01:09 UTC by Dustin Boyd
Modified: 2021-04-04 10:12 UTC (History)
3 users (show)

See Also:


Attachments
Honor MANSECT and -S section-list when matching section names (401 bytes, patch)
2020-09-14 01:09 UTC, Dustin Boyd
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dustin Boyd 2020-09-14 01:09:15 UTC
Created attachment 217939 [details]
Honor MANSECT and -S section-list when matching section names

man(1) relies on the default list of manual sections when determining whether an argument is a section name, completely ignoring the MANSECT environment variable and the sections listed in the argument to the -S option.

I encountered this behavior when trying to determine why

    man -S '1:3p' '3p' printf

would open printf(1) instead of printf(3p) after installing man-pages-posix[1], yet

    man -S '3p' printf

worked correctly.

Attached is a patch that ensures the section list provided by either the -S option (which sets the MANSECT shell variable) or the MANSECT environment variable is searched if they don't expand to an empty string, else the default section list is searched.  It intentionally avoids setting the MANSECT shell variable since that's taken care of later by the man_setup() function.

[1]: https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/man-pages-posix/