git: b006133ca117 - stable/14 - shar: Handle special characters or white space in file names fed to shar

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Tue, 25 Feb 2025 00:37:57 UTC
The branch stable/14 has been updated by cy:

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

commit b006133ca1176a89abd3f96bb87989a85342f6a8
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2025-01-02 03:35:31 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2025-02-25 00:37:46 +0000

    shar: Handle special characters or white space in file names fed to shar
    
    Obtained from:  NetBSD hg commit 365370:124268924386
    MFC after:      1 week
    
    (cherry picked from commit 1080f5315427b382221651b342227b4923106f83)
---
 usr.bin/shar/shar.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/usr.bin/shar/shar.sh b/usr.bin/shar/shar.sh
index 77ef3789c8b3..f7496716acba 100644
--- a/usr.bin/shar/shar.sh
+++ b/usr.bin/shar/shar.sh
@@ -64,14 +64,14 @@ echo "#"
 
 for i
 do
-	if [ -d $i ]; then
-		echo "echo c - $i"
-		echo "mkdir -p $i > /dev/null 2>&1"
+	if [ -d "$i" ]; then
+		echo "echo c - '$i'"
+		echo "mkdir -p '$i' > /dev/null 2>&1"
 	else
-		md5sum=`echo -n $i | md5`
-		echo "echo x - $i"
-		echo "sed 's/^X//' >$i << '$md5sum'"
-		sed 's/^/X/' $i || exit
+		md5sum=`echo -n "$i" | md5`
+		echo "echo x - '$i'"
+		echo "sed 's/^X//' >'$i' << '$md5sum'"
+		sed 's/^/X/' "$i" || exit
 		echo "$md5sum"
 	fi
 done