projects
/
debian
/
gzip
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
patch to improve behavior of zdiff when file is compressed without extension
[debian/gzip]
/
zdiff.in
diff --git
a/zdiff.in
b/zdiff.in
index 9d3b4aed0a1bd842b84a1b7e71ba2fa987d367af..506a888ef2d78390d9d6e8eec497b63c37d673a5 100644
(file)
--- a/
zdiff.in
+++ b/
zdiff.in
@@
-76,9
+76,15
@@
gzip_status=0
exec 3>&1
if test $# -eq 1; then
exec 3>&1
if test $# -eq 1; then
- case $1 in
- *[-.]gz* | *[-.][zZ] | *.t[ga]z)
+ type_file=$(file -b --mime-type "$1")
+
+ case $type_file in
+ application/x-gzip | application/x-compress)
FILE=`expr "X$1" : 'X\(.*\)[-.][zZtga]*$'`
FILE=`expr "X$1" : 'X\(.*\)[-.][zZtga]*$'`
+ if test "$FILE" == ""; then
+ FILE="$1"
+ fi;
+
gzip_status=$(
exec 4>&1
(gzip -cd -- "$1" 4>&-; echo $? >&4) 3>&- | eval "$cmp" - '"$FILE"' >&3
gzip_status=$(
exec 4>&1
(gzip -cd -- "$1" 4>&-; echo $? >&4) 3>&- | eval "$cmp" - '"$FILE"' >&3
@@
-88,10
+94,13
@@
if test $# -eq 1; then
exit 2;;
esac
elif test $# -eq 2; then
exit 2;;
esac
elif test $# -eq 2; then
- case "$1" in
- *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
- case "$2" in
- *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
+ 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
if test "$1$2" = --; then
gzip_status=$(
exec 4>&1
@@
-118,6
+127,9
@@
elif test $# -eq 2; then
(exit $cmp_status)
else
F=`expr "/$2" : '.*/\(.*\)[-.][zZtga]*$'` || F=$prog
(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"
tmp=
trap '
test -n "$tmp" && rm -f "$tmp"
@@
-147,8
+159,8
@@
elif test $# -eq 2; then
eval "$cmp" - '"$2"' >&3
);;
esac;;
eval "$cmp" - '"$2"' >&3
);;
esac;;
- *) case "$2" in
-
*[-.]gz* | *[-.][zZ] | *.t[ga]z | -
)
+ *) case "$
type_file
2" in
+
application/x-gzip | application/x-compress
)
gzip_status=$(
exec 4>&1
(gzip -cdfq -- "$2" 4>&-; echo $? >&4) 3>&- |
gzip_status=$(
exec 4>&1
(gzip -cdfq -- "$2" 4>&-; echo $? >&4) 3>&- |