OSSP CVS Repository

ossp - Difference in ossp-pkg/svs/svs.sh versions 1.10 and 1.11
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/svs/svs.sh 1.10 -> 1.11

--- svs.sh       2005/10/07 10:59:27     1.10
+++ svs.sh       2009/06/25 18:10:41     1.11
@@ -39,18 +39,22 @@
 
 #   helper function for portable creating a file difference
 do_diff () {
-    diff -U3 $1 $2 2>/dev/null
+    diff -U3 "$1" "$2" 2>/dev/null
     if [ $? -gt 1 ]; then
-        diff -u $1 $2 2>/dev/null
+        diff -u "$1" "$2" 2>/dev/null
         if [ $? -gt 1 ]; then
-            diff -C3 $1 $2 2>/dev/null
+            diff -C3 "$1" "$2" 2>/dev/null
             if [ $? -gt 1 ]; then
-                diff $1 $2
+                diff "$1" "$2"
             fi
         fi
     fi
 }
 
+#   a newline character
+NL='
+'
+
 #   dispatch into commands
 cmd="$1"
 shift
@@ -63,34 +67,34 @@
         #   iterate over all files
         for file in "$@"; do
             #   preserve original file
-            if [ ! -f $file.orig ]; then
-                cp -p $file $file.orig
+            if [ ! -f "$file.orig" ]; then
+                cp -p "$file" "$file.orig"
                 orig=new
             else
                 orig=old
             fi
 
             #   edit file
-            chmod u+w $file
-            if [ ".${EDITOR-vi}" = .vim -a -f $file.rej ]; then
-                ${EDITOR-vi} -o2 $file $file.rej
+            chmod u+w "$file"
+            if [ ".${EDITOR-vi}" = .vim -a -f "$file.rej" ]; then
+                ${EDITOR-vi} -o2 "$file" "$file.rej"
             else
-                ${EDITOR-vi} $file
+                ${EDITOR-vi} "$file"
             fi
 
             #   check for editing results
-            if cmp $file.orig $file >/dev/null 2>&1; then
+            if cmp "$file.orig" "$file" >/dev/null 2>&1; then
                 if [ ".$orig" = .new ]; then
                     echo "svs: no changes made (keeping original)"
                 else
                     echo "svs: changes reversed (restoring original)"
                 fi
-                cp -p $file.orig $file
-                rm -f $file.orig
+                cp -p "$file.orig" "$file"
+                rm -f "$file.orig"
             else
                 echo "svs: changes made (preserving original)"
-                if [ -f $file.rej ]; then
-                    rm -f $file.rej
+                if [ -f "$file.rej" ]; then
+                    rm -f "$file.rej"
                 fi
             fi
         done
@@ -107,12 +111,14 @@
         fi
         files=""
         for file in "$@"; do
-            if [ -d $file ]; then
-                for f in `find $file -type f -name "*.orig" -print | sort`; do
-                    files="$files $f"
+            if [ -d "$file" ]; then
+                OIFS=$IFS; IFS=$NL
+                for f in `find "$file" -type f -name "*.orig" -print | sort`; do
+                    files="$files \"$f\""
                 done
-            elif [ -f $file ]; then
-                files="$files $file"
+                IFS=$OIFS
+            elif [ -f "$file" ]; then
+                files="$files \"$file\""
             else
                 echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2
                 exit 1
@@ -120,29 +126,30 @@
         done
 
         #   generate patch
-        for file in $files; do
+        eval set -- $files
+        for file; do
             file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'`
             orig=`echo "$file" | sed -e 's;\.orig$;;' -e 's;$;.orig;'`
             edit=`echo "$file" | sed -e 's;\.orig$;;'`
-            if [ ! -f $orig ]; then
+            if [ ! -f "$orig" ]; then
                 echo "svs:WARNING: original file \"$orig\" not found" 1>&2
                 continue
             fi
-            if [ ! -f $edit ]; then
+            if [ ! -f "$edit" ]; then
                 #   special case: removed file
                 echo "Index: $edit"
-                do_diff $orig /dev/null | sed -e "1s/^--- $orig/--- $edit/"
-            elif [ ! -r $orig ] && [ ! -s $orig ]; then
+                do_diff "$orig" /dev/null | sed -e "1s/^--- $orig/--- $edit/"
+            elif [ ! -r "$orig" ] && [ ! -s "$orig" ]; then
                 #   special case: new file
                 echo "Index: $edit"
-                do_diff /dev/null $edit
+                do_diff /dev/null "$edit"
             else
                 #   regular case: edited file
-                if cmp $orig $edit >/dev/null 2>&1; then
+                if cmp "$orig" "$edit" >/dev/null 2>&1; then
                     :
                 else
                     echo "Index: $edit"
-                    do_diff $orig $edit
+                    do_diff "$orig" "$edit"
                 fi
             fi
         done
@@ -159,12 +166,14 @@
         fi
         files=""
         for file in "$@"; do
-            if [ -d $file ]; then
-                for f in `find $file -type f -name "*.orig" -print | sort`; do
-                    files="$files $f"
+            if [ -d "$file" ]; then
+                OIFS=$IFS; IFS=$NL
+                for f in `find "$file" -type f -name "*.orig" -print | sort`; do
+                    files="$files \"$f\""
                 done
-            elif [ -f $file ]; then
-                files="$files $file"
+                IFS=$OIFS
+            elif [ -f "$file" ]; then
+                files="$files \"$file\""
             else
                 echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2
                 exit 1
@@ -172,28 +181,29 @@
         done
 
         #   backout changes
-        for file in $files; do
+        eval set -- $files
+        for file; do
             file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'`
             orig=`echo "$file" | sed -e 's;\.orig$;;' -e 's;$;.orig;'`
             edit=`echo "$file" | sed -e 's;\.orig$;;'`
-            if [ ! -f $orig ]; then
+            if [ ! -f "$orig" ]; then
                 echo "svs:WARNING: original file \"$orig\" not found" 1>&2
                 continue
             fi
             echo "svs: backing out changes to \"$edit\""
-            if [ ! -f $edit ]; then
+            if [ ! -f "$edit" ]; then
                 #   special case: removed file
-                cp -p $orig $edit
-                rm -f $orig
-            elif [ ! -r $orig ] && [ ! -s $orig ]; then
+                cp -p "$orig" "$edit"
+                rm -f "$orig"
+            elif [ ! -r "$orig" ] && [ ! -s "$orig" ]; then
                 #   special case: new file
-                chmod u+w $orig
-                rm -f $orig
-                rm -f $edit
+                chmod u+w "$orig"
+                rm -f "$orig"
+                rm -f "$edit"
             else
                 #   regular case: edited file
-                cp -p $orig $edit
-                rm -f $orig
+                cp -p "$orig" "$edit"
+                rm -f "$orig"
             fi
         done
         ;;
@@ -209,16 +219,18 @@
         fi
         files=""
         for file in "$@"; do
-            if [ -d $file ]; then
-                for f in `find $file -type f \( -name "*.orig" -or -name "*.rej" \) -print | sort`; do
+            if [ -d "$file" ]; then
+                OIFS=$IFS; IFS=$NL
+                for f in `find "$file" -type f \( -name "*.orig" -or -name "*.rej" \) -print | sort`; do
                     base=`echo "$f" | sed -e 's;\.orig$;;' -e 's;\.rej$;;'`
-                    if [ ".$f" = ".$base.orig" ] && [ -f $base.orig ] && [ -f $base.rej ]; then
+                    if [ ".$f" = ".$base.orig" ] && [ -f "$base.orig" ] && [ -f "$base.rej" ]; then
                         continue
                     fi
-                    files="$files $f"
+                    files="$files \"$f\""
                 done
-            elif [ -f $file ]; then
-                files="$files $file"
+                IFS=$OIFS
+            elif [ -f "$file" ]; then
+                files="$files \"$file\""
             else
                 echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2
                 exit 1
@@ -226,7 +238,8 @@
         done
 
         #   show status on files
-        for file in $files; do
+        eval set -- $files
+        for file; do
             file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'`
             base=`echo "$file" | sed -e 's;\.orig$;;' -e 's;\.rej$;;'`
             prefix="?"

CVSTrac 2.0.1