git: 05daf917987e - stable/13 - improve handling of shell metacharacters in filenames

From: Wolfram Schneider <wosch_at_FreeBSD.org>
Date: Fri, 05 Jan 2024 08:20:04 UTC
The branch stable/13 has been updated by wosch:

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

commit 05daf917987e2e5e29fa0f8a4bfb519f6d2ec953
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2023-12-27 17:35:08 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2024-01-05 08:19:10 +0000

    improve handling of shell metacharacters in filenames
    
    PR:             275967
    MFC after:      1 week
    
    (cherry picked from commit c4368d03e52c7c97d583ee6b81a59510d371ffbb)
---
 usr.bin/man/man.sh | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index 96040c533de5..ed5724d64678 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -118,8 +118,8 @@ check_cat() {
 	if exists "$1"; then
 		use_cat=yes
 		catpage=$found
-		setup_cattool $catpage
-		decho "    Found catpage $catpage"
+		setup_cattool "$catpage"
+		decho "    Found catpage \"$catpage\""
 		return 0
 	else
 		return 1
@@ -144,8 +144,8 @@ check_man() {
 			# cat page found and is newer, use that
 			use_cat=yes
 			catpage=$found
-			setup_cattool $catpage
-			decho "    Using catpage $catpage"
+			setup_cattool "$catpage"
+			decho "    Using catpage \"$catpage\""
 		else
 			# no cat page or is older
 			unset use_cat
@@ -317,10 +317,10 @@ man_display_page() {
 			ret=0
 		else
 			if [ $debug -gt 0 ]; then
-				decho "Command: $cattool $catpage | $MANPAGER"
+				decho "Command: $cattool \"$catpage\" | $MANPAGER"
 				ret=0
 			else
-				eval "$cattool $catpage | $MANPAGER"
+				eval "$cattool \"$catpage\" | $MANPAGER"
 				ret=$?
 			fi
 		fi
@@ -345,7 +345,7 @@ man_display_page() {
 		pipeline="mandoc $mandoc_args | $MANPAGER"
 	fi
 
-	if ! eval "$cattool $manpage | $testline" ;then
+	if ! eval "$cattool \"$manpage\" | $testline" ;then
 		if which -s groff; then
 			man_display_page_groff
 		else
@@ -358,10 +358,10 @@ man_display_page() {
 	fi
 
 	if [ $debug -gt 0 ]; then
-		decho "Command: $cattool $manpage | $pipeline"
+		decho "Command: $cattool \"$manpage\" | $pipeline"
 		ret=0
 	else
-		eval "$cattool $manpage | $pipeline"
+		eval "$cattool \"$manpage\" | $pipeline"
 		ret=$?
 	fi
 }
@@ -451,10 +451,10 @@ man_display_page_groff() {
 	fi
 
 	if [ $debug -gt 0 ]; then
-		decho "Command: $cattool $manpage | $pipeline"
+		decho "Command: $cattool \"$manpage\" | $pipeline"
 		ret=0
 	else
-		eval "$cattool $manpage | $pipeline"
+		eval "$cattool \"$manpage\" | $pipeline"
 		ret=$?
 	fi
 }