gzip 1.3.5
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 26 Sep 2002 08:33:24 +0000 (08:33 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 26 Sep 2002 08:33:24 +0000 (08:33 +0000)
zdiff.in

index 110454ccf84a5d64b0e0617ec48d0b150808e9ae..819019286637e61c5510578617e180617be0822b 100644 (file)
--- a/zdiff.in
+++ b/zdiff.in
@@ -27,19 +27,18 @@ do
             FILES="$FILES $ARG"
         else
             echo "${prog}: $ARG not found or not a regular file"
-           exit 1
+           exit 2
         fi ;;
     esac
 done
 if test -z "$FILES"; then
        echo "Usage: $prog [${comp}_options] file [file]"
-       exit 1
+       exit 2
 fi
 set $FILES
 if test $# -eq 1; then
        FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'`
        gzip -cd "$1" | $comp $OPTIONS - "$FILE"
-       STAT="$?"
 
 elif test $# -eq 2; then
        case "$1" in
@@ -47,24 +46,24 @@ elif test $# -eq 2; then
                 case "$2" in
                *[-.]gz* | *[-.][zZ] | *.t[ga]z)
                        F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'`
-                        gzip -cdfq "$2" > /tmp/"$F".$$
+                       set -C
+                       trap 'rm -f /tmp/"$F".$$; exit 2' HUP INT PIPE TERM 0
+                       gzip -cdfq "$2" > /tmp/"$F".$$ || exit
                         gzip -cdfq "$1" | $comp $OPTIONS - /tmp/"$F".$$
                         STAT="$?"
-                       /bin/rm -f /tmp/"$F".$$;;
+                       /bin/rm -f /tmp/"$F".$$ || STAT=2
+                       trap - HUP INT PIPE TERM 0
+                       exit $STAT;;
 
-                *)      gzip -cdfq "$1" | $comp $OPTIONS - "$2"
-                        STAT="$?";;
+                *)      gzip -cdfq "$1" | $comp $OPTIONS - "$2";;
                 esac;;
         *)      case "$2" in
                *[-.]gz* | *[-.][zZ] | *.t[ga]z)
-                        gzip -cdfq "$2" | $comp $OPTIONS "$1" -
-                        STAT="$?";;
-                *)      $comp $OPTIONS "$1" "$2"
-                        STAT="$?";;
+                        gzip -cdfq "$2" | $comp $OPTIONS "$1" -;;
+                *)      $comp $OPTIONS "$1" "$2";;
                 esac;;
        esac
-        exit "$STAT"
 else
        echo "Usage: $prog [${comp}_options] file [file]"
-       exit 1
+       exit 2
 fi