git: 73eb53813fe3 - main - man(1) needs to check for .so files not only in the first line PR: 279182

From: Wolfram Schneider <wosch_at_FreeBSD.org>
Date: Sun, 26 May 2024 05:51:56 UTC
The branch main has been updated by wosch:

URL: https://cgit.FreeBSD.org/src/commit/?id=73eb53813fe3a2245edbeb670902e4bb9d41e288

commit 73eb53813fe3a2245edbeb670902e4bb9d41e288
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2024-05-26 05:48:40 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2024-05-26 05:48:40 +0000

    man(1) needs to check for .so files not only in the first line
    PR: 279182
    
    Some manual pages have a copyright notice or commit id before including
    other files with the .so macro. We need to skip comments and empty lines
    at the beginning of the manpage while checking for the first .so macro.
    
    MFC after:      1 week
---
 usr.bin/man/man.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index af638527f497..24a0464689cc 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -322,7 +322,7 @@ man_check_for_so() {
 	# We need to loop to accommodate multiple .so directives.
 	while true
 	do
-		line=$($cattool "$manpage" 2>/dev/null | head -n1)
+		line=$($cattool "$manpage" 2>/dev/null | grep -E -m1 -v '^\.\\"[ ]*|^[ ]*$')
 		case "$line" in
 		.so*)	trim "${line#.so}"
 			decho "$manpage includes $tstr"