git: 5e78db7b45ed - stable/13 - support spaces in filenames

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

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

commit 5e78db7b45ede9b8799fa0d293d282842aa00cc0
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2023-12-28 10:50:29 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2024-01-05 08:21:29 +0000

    support spaces in filenames
    
    PR:             275978
    MFC after:      1 week
    
    (cherry picked from commit 789480702e490818244af11279868ba4f3dabe6b)
---
 usr.bin/man/man.sh | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index ed5724d64678..114ea9d7a0b2 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -133,14 +133,14 @@ check_man() {
 	if exists "$1"; then
 		# We have a match, check for a cat page
 		manpage=$found
-		setup_cattool $manpage
-		decho "    Found manpage $manpage"
+		setup_cattool "$manpage"
+		decho "    Found manpage \"$manpage\""
 
 		if [ -n "${use_width}" ]; then
 			# non-standard width
 			unset use_cat
 			decho "    Skipping catpage: non-standard page width"
-		elif exists "$2" && is_newer $found $manpage; then
+		elif exists "$2" && is_newer $found "$manpage"; then
 			# cat page found and is newer, use that
 			use_cat=yes
 			catpage=$found
@@ -283,7 +283,7 @@ man_check_for_so() {
 	# We need to loop to accommodate multiple .so directives.
 	while true
 	do
-		line=$($cattool $manpage | head -1)
+		line=$($cattool "$manpage" | head -1)
 		case "$line" in
 		.so*)	trim "${line#.so}"
 			decho "$manpage includes $tstr"
@@ -313,7 +313,7 @@ man_display_page() {
 	# just zcat the catpage and we are done.
 	if [ -z "$tflag" -a -n "$use_cat" ]; then
 		if [ -n "$wflag" ]; then
-			echo "$catpage (source: $manpage)"
+			echo "$catpage (source: \"$manpage\")"
 			ret=0
 		else
 			if [ $debug -gt 0 ]; then
@@ -471,8 +471,8 @@ man_find_and_display() {
 			decho "Found a usable page, displaying that"
 			unset use_cat
 			manpage="$1"
-			setup_cattool $manpage
-			if man_check_for_so $manpage $(dirname $manpage); then
+			setup_cattool "$manpage"
+			if man_check_for_so "$manpage" "$(dirname \"$manpage"")"; then
 				found_page=yes
 				man_display_page
 			fi
@@ -491,7 +491,7 @@ man_find_and_display() {
 
 				# Check if there is a MACHINE specific manpath.
 				if find_file $p $sect $MACHINE "$1"; then
-					if man_check_for_so $manpage $p; then
+					if man_check_for_so "$manpage" $p; then
 						found_page=yes
 						man_display_page
 						if [ -n "$aflag" ]; then
@@ -505,7 +505,7 @@ man_find_and_display() {
 				# Check if there is a MACHINE_ARCH
 				# specific manpath.
 				if find_file $p $sect $MACHINE_ARCH "$1"; then
-					if man_check_for_so $manpage $p; then
+					if man_check_for_so "$manpage" $p; then
 						found_page=yes
 						man_display_page
 						if [ -n "$aflag" ]; then
@@ -518,7 +518,7 @@ man_find_and_display() {
 
 				# Check plain old manpath.
 				if find_file $p $sect '' "$1"; then
-					if man_check_for_so $manpage $p; then
+					if man_check_for_so "$manpage" $p; then
 						found_page=yes
 						man_display_page
 						if [ -n "$aflag" ]; then
@@ -535,7 +535,7 @@ man_find_and_display() {
 
 	# Nothing? Well, we are done then.
 	if [ -z "$found_page" ]; then
-		echo "No manual entry for $1" >&2
+		echo "No manual entry for \"$1\"" >&2
 		ret=1
 		return
 	fi
@@ -973,8 +973,8 @@ do_man() {
 	fi
 	man_setup
 
-	for page in $pages; do
-		decho "Searching for $page"
+	for page in "$pages"; do
+		decho "Searching for \"$page\""
 		man_find_and_display "$page"
 	done