git: e1f5c22be431 - stable/14 - man(1) needs to check for .so files not only in the first line PR: 279182

From: Wolfram Schneider <wosch_at_FreeBSD.org>
Date: Mon, 03 Jun 2024 16:34:37 UTC
The branch stable/14 has been updated by wosch:

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

commit e1f5c22be4317523102a98f7f62c780fbe73b40f
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2024-05-26 05:48:40 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2024-06-03 16:23:05 +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
    
    (cherry picked from commit 73eb53813fe3a2245edbeb670902e4bb9d41e288)
---
 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 e8eb27850873..ec14fe08cf67 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"