git: 37be4197f72a - main - man: the exists function needs to validate the first parameter

From: Wolfram Schneider <wosch_at_FreeBSD.org>
Date: Mon, 20 May 2024 16:08:27 UTC
The branch main has been updated by wosch:

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

commit 37be4197f72ae3a61bd5e93d2ebdc9bd6d09ed21
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2024-05-20 16:02:21 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2024-05-20 16:02:21 +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 03803b777463..af638527f497 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -201,6 +201,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)