OSSP CVS Repository

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

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

--- svs.sh       2005/10/03 10:33:48     1.9
+++ svs.sh       2005/10/07 10:59:27     1.10
@@ -37,6 +37,20 @@
     exit 1
 fi
 
+#   helper function for portable creating a file difference
+do_diff () {
+    diff -U3 $1 $2 2>/dev/null
+    if [ $? -gt 1 ]; then
+        diff -u $1 $2 2>/dev/null
+        if [ $? -gt 1 ]; then
+            diff -C3 $1 $2 2>/dev/null
+            if [ $? -gt 1 ]; then
+                diff $1 $2
+            fi
+        fi
+    fi
+}
+
 #   dispatch into commands
 cmd="$1"
 shift
@@ -117,28 +131,18 @@
             if [ ! -f $edit ]; then
                 #   special case: removed file
                 echo "Index: $edit"
-                ( diff -U3 $orig /dev/null 2>/dev/null ||\
-                  diff -u  $orig /dev/null 2>/dev/null ||\
-                  diff -C3 $orig /dev/null 2>/dev/null ||\
-                  diff     $orig /dev/null
-                ) | sed -e "1s/^--- $orig/--- $edit/"
+                do_diff $orig /dev/null | sed -e "1s/^--- $orig/--- $edit/"
             elif [ ! -r $orig ] && [ ! -s $orig ]; then
                 #   special case: new file
                 echo "Index: $edit"
-                diff -U3 /dev/null $edit 2>/dev/null ||\
-                diff -u  /dev/null $edit 2>/dev/null ||\
-                diff -C3 /dev/null $edit 2>/dev/null ||\
-                diff     /dev/null $edit
+                do_diff /dev/null $edit
             else
                 #   regular case: edited file
                 if cmp $orig $edit >/dev/null 2>&1; then
                     :
                 else
                     echo "Index: $edit"
-                    diff -U3 $orig $edit 2>/dev/null ||\
-                    diff -u  $orig $edit 2>/dev/null ||\
-                    diff -C3 $orig $edit 2>/dev/null ||\
-                    diff     $orig $edit
+                    do_diff $orig $edit
                 fi
             fi
         done

CVSTrac 2.0.1