bzdiff.diff   [plain text]


--- bzdiff.orig	2008-07-14 19:50:14.000000000 -0700
+++ bzdiff	2008-07-14 20:44:07.000000000 -0700
@@ -20,28 +20,29 @@
 esac
 
 OPTIONS=
-FILES=
 for ARG
 do
     case "$ARG" in
-    -*)	OPTIONS="$OPTIONS $ARG";;
-     *)	if test -f "$ARG"; then
-            FILES="$FILES $ARG"
-        else
-            echo "${prog}: $ARG not found or not a regular file"
-	    exit 1
-        fi ;;
+    -*)	OPTIONS="$OPTIONS $ARG"; shift;;
+     *)	break;;
     esac
 done
-if test -z "$FILES"; then
+if [ $# -eq 0 ] || [ $# -gt 2 ]; then
 	echo "Usage: $prog [${comp}_options] file [file]"
 	exit 1
 fi
+if [ ! -f "$1" ]; then
+	echo "${prog}: $1 not found or not a regular file"
+	exit 1
+fi
+if [ $# -eq 2 ] && [ ! -f "$2" ]; then
+	echo "${prog}: $2 not found or not a regular file"
+	exit 1
+fi
 tmp=`mktemp ${TMPDIR:-/tmp}/bzdiff.XXXXXXXXXX` || {
       echo 'cannot create a temporary file' >&2
       exit 1
 }
-set $FILES
 if test $# -eq 1; then
 	FILE=`echo "$1" | sed 's/.bz2$//'`
 	bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE"
@@ -70,7 +71,4 @@
                 esac;;
 	esac
         exit "$STAT"
-else
-	echo "Usage: $prog [${comp}_options] file [file]"
-	exit 1
 fi