git: 432c0128bd3d - stable/14 - man: the exists function needs to validate the first parameter

From: Wolfram Schneider <wosch_at_FreeBSD.org>
Date: Sun, 26 May 2024 05:36:19 UTC
The branch stable/14 has been updated by wosch:

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

commit 432c0128bd3da3f7800e9fa525d677f8fb99d7a1
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2024-05-20 16:02:21 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2024-05-26 05:34:40 +0000

    man: the exists function needs to validate the first parameter
    
    This fixes an issue with the ".so " macro for FreeBSD
    ports manual pages.
    
    PR: 275978
    Reported by:    Jamie Landeg-Jones <jamie@catflap.org>
    MFC after:      1 week
    
    Differential Revision:  https://reviews.freebsd.org/D45231 (discussion)
---
 usr.bin/man/man.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index cd047862727d..a4d23ff52aef 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -195,6 +195,10 @@ decho() {
 # Returns true if glob resolves to a real file and store the first
 # found filename in the variable $found
 exists() {
+	if [ -z "$1" ]; then
+		return 1
+	fi
+
 	local IFS
 
 	# Don't accidentally inherit callers IFS (breaks perl manpages)