- case "$1" in
- *[-.]gz* | *[-.][zZ] | *.t[ga]z)
- case "$2" in
- *[-.]gz* | *[-.][zZ] | *.t[ga]z)
- F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'`
- set -C
- trap 'rm -f /tmp/"$F".$$; exit 2' 1 2 13 15 0
- gzip -cdfq "$2" > /tmp/"$F".$$ || exit
- gzip -cdfq "$1" | $comp $OPTIONS - /tmp/"$F".$$
- STAT="$?"
- /bin/rm -f /tmp/"$F".$$ || STAT=2
- trap 1 2 13 15 0
- exit $STAT;;
-
- *) gzip -cdfq "$1" | $comp $OPTIONS - "$2";;
+ type_file1=$(file -b --mime-type "$1")
+ type_file2=$(file -b --mime-type "$2")
+
+ case "$type_file1" in
+ application/x-gzip | application/x-compress)
+ case "$type_file2" in
+ application/x-gzip | application/x-compress)
+ if test "$1$2" = --; then
+ gzip_status=$(
+ exec 4>&1
+ (gzip -cdfq - 4>&-; echo $? >&4) 3>&- |
+ eval "$cmp" - - >&3
+ )
+ elif
+ # Reject Solaris 8's buggy /bin/bash 2.03.
+ echo X |
+ (echo X | eval "$cmp" /dev/fd/5 - >/dev/null 2>&1) \
+ 5<&0
+ then
+ gzip_status=$(
+ exec 4>&1
+ (gzip -cdfq -- "$1" 4>&-; echo $? >&4) 3>&- |
+ ( (gzip -cdfq -- "$2" 4>&-; echo $? >&4) 3>&- 5<&- </dev/null |
+ eval "$cmp" /dev/fd/5 - >&3) 5<&0
+ )
+ cmp_status=$?
+ case $gzip_status in
+ *[1-9]*) gzip_status=1;;
+ *) gzip_status=0;;
+ esac
+ (exit $cmp_status)
+ else
+ F=`expr "/$2" : '.*/\(.*\)[-.][zZtga]*$'` || F=$prog
+ if test "$F" == ""; then
+ F="$2"
+ fi;
+ tmp=
+ trap '
+ test -n "$tmp" && rm -f "$tmp"
+ (exit 2); exit 2
+ ' HUP INT PIPE TERM 0
+ if type mktemp >/dev/null 2>&1; then
+ tmp=`mktemp -t -- "$F.XXXXXX"` || exit 2
+ else
+ set -C
+ tmp=${TMPDIR-/tmp}/$F.$$
+ fi
+ gzip -cdfq -- "$2" > "$tmp" || exit 2
+ gzip_status=$(
+ exec 4>&1
+ (gzip -cdfq -- "$1" 4>&-; echo $? >&4) 3>&- |
+ eval "$cmp" - '"$tmp"' >&3
+ )
+ cmp_status=$?
+ rm -f "$tmp" || gzip_status=$?
+ trap - HUP INT PIPE TERM 0
+ (exit $cmp_status)
+ fi;;
+ *)
+ gzip_status=$(
+ exec 4>&1
+ (gzip -cdfq -- "$1" 4>&-; echo $? >&4) 3>&- |
+ eval "$cmp" - '"$2"' >&3
+ );;