Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/shar better handle special characters or white space...



details:   https://anonhg.NetBSD.org/src/rev/124268924386
branches:  trunk
changeset: 372858:124268924386
user:      ginsbach <ginsbach%NetBSD.org@localhost>
date:      Sat Dec 31 03:38:59 2022 +0000

description:
better handle special characters or white space in file names fed to shar

Code from Dave Sainty in PR bin/11107

diffstat:

 usr.bin/shar/shar.sh |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (31 lines):

diff -r 21b92f0055b4 -r 124268924386 usr.bin/shar/shar.sh
--- a/usr.bin/shar/shar.sh      Sat Dec 31 03:33:53 2022 +0000
+++ b/usr.bin/shar/shar.sh      Sat Dec 31 03:38:59 2022 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-#      $NetBSD: shar.sh,v 1.4 2022/12/31 03:33:53 ginsbach Exp $
+#      $NetBSD: shar.sh,v 1.5 2022/12/31 03:38:59 ginsbach Exp $
 #
 # Copyright (c) 1990, 1993
 #      The Regents of the University of California.  All rights reserved.
@@ -56,13 +56,13 @@
 
 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
-               echo "echo x - $i"
-               echo "sed 's/^X//' >$i << 'END-of-$i'"
-               sed 's/^/X/' $i || exit 1
+               echo "echo x - '$i'"
+               echo "sed 's/^X//' >'$i' << 'END-of-$i'"
+               sed 's/^/X/' "$i" || exit 1
                echo "END-of-$i"
        fi
 done



Home | Main Index | Thread Index | Old Index