Bug 279774 - man(1) displays first file from current directory instead of .so file
Summary: man(1) displays first file from current directory instead of .so file
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.1-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-15 21:08 UTC by Sean Donelan
Modified: 2024-06-15 21:08 UTC (History)
0 users

See Also:


Attachments
patch for usr.bin/man.sh to check null filename (363 bytes, patch)
2024-06-15 21:08 UTC, Sean Donelan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Donelan 2024-06-15 21:08:11 UTC
Created attachment 251480 [details]
patch for usr.bin/man.sh to check null filename

When a manpage contains a .so link to a second manpage, man(1) displays first file in current directory

The function exists() in man.sh uses file globbing to check if file exists. When called with a null filename, such as when redirecting .so link to new manpage file, globbing returns the name of the first file in the current directory.

sean@clifden:~ % zgrep -e "^\.so" /usr/local/share/man/man1/doveadm-backup*
/usr/local/share/man/man1/doveadm-backup.1.gz:.so man1/doveadm-sync.1

sean@clifden:~ % man -w doveadm-backup
a-file-in-directory (source: "/usr/local/share/man/man1/doveadm-sync.1.gz")

Patched result

sean@clifden:/usr/bin % man -w doveadm-backup
/usr/local/share/man/man1/doveadm-sync.1.gz