Adding upstream version 0.7.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
c2bdc739f1
commit
0504e18b91
17 changed files with 318 additions and 96 deletions
46
zdiff.in
46
zdiff.in
|
@ -23,7 +23,7 @@ while [ x"$1" != x ] ; do
|
|||
echo "Zdiff is a wrapper script around the diff and cmp commands that allows"
|
||||
echo "transparent comparison of any combination of compressed and"
|
||||
echo "non-compressed files. If any given file is compressed, its uncompressed"
|
||||
echo "content is used. The supported compressors are gzip, bzip2, lzip and xz."
|
||||
echo "content is used. The supported compressors are bzip2, gzip, lzip and xz."
|
||||
echo
|
||||
echo "Zcmp is a shortcut for \"zdiff --cmp\""
|
||||
echo
|
||||
|
@ -33,7 +33,7 @@ while [ x"$1" != x ] ; do
|
|||
echo "compares FILE1 to the file with the corresponding decompressed file"
|
||||
echo "name (removes the extension from FILE1). If FILE2 is omitted and FILE1"
|
||||
echo "is not compressed, compares FILE1 to the uncompressed contents of"
|
||||
echo "FILE1.[gz|bz2|lz|xz] (the first one that is found)."
|
||||
echo "FILE1.[bz2|gz|lz|xz] (the first one that is found)."
|
||||
echo "DIFF_OPTIONS are passed directly to diff or cmp."
|
||||
echo "The exit status from diff or cmp is preserved."
|
||||
echo
|
||||
|
@ -73,10 +73,10 @@ done
|
|||
for i in "$@" ; do
|
||||
if [ "$i" = "--" ] && [ ${two_hyphens} = 0 ] ; then two_hyphens=1
|
||||
else
|
||||
if [ -f "$i" ]; then
|
||||
if [ -z "${file1}" ]; then file1="$i"
|
||||
if [ -f "$i" ] ; then
|
||||
if [ -z "${file1}" ] ; then file1="$i"
|
||||
else
|
||||
if [ -z "${file2}" ]; then file2="$i"
|
||||
if [ -z "${file2}" ] ; then file2="$i"
|
||||
else
|
||||
echo "$0: Too many files; use --help for usage." 1>&2
|
||||
fi
|
||||
|
@ -88,27 +88,27 @@ for i in "$@" ; do
|
|||
fi
|
||||
done
|
||||
|
||||
if [ -z "${file1}" ]; then
|
||||
if [ -z "${file1}" ] ; then
|
||||
echo "$0: No files given; use --help for usage." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${file2}" ]; then
|
||||
if [ -z "${file2}" ] ; then
|
||||
case "${file1}" in
|
||||
*.gz) file2=`printf "%s" "${file1}" | sed -e 's,.gz$,,'` ;;
|
||||
*.tgz) file2=`printf "%s" "${file1}" | sed -e 's,tgz$,tar,'` ;;
|
||||
*.bz2) file2=`printf "%s" "${file1}" | sed -e 's,.bz2$,,'` ;;
|
||||
*.tbz) file2=`printf "%s" "${file1}" | sed -e 's,tbz$,tar,'` ;;
|
||||
*.tbz2) file2=`printf "%s" "${file1}" | sed -e 's,tbz2$,tar,'` ;;
|
||||
*.gz) file2=`printf "%s" "${file1}" | sed -e 's,.gz$,,'` ;;
|
||||
*.tgz) file2=`printf "%s" "${file1}" | sed -e 's,tgz$,tar,'` ;;
|
||||
*.lz) file2=`printf "%s" "${file1}" | sed -e 's,.lz$,,'` ;;
|
||||
*.tlz) file2=`printf "%s" "${file1}" | sed -e 's,tlz$,tar,'` ;;
|
||||
*.xz) file2=`printf "%s" "${file1}" | sed -e 's,.xz$,,'` ;;
|
||||
*.txz) file2=`printf "%s" "${file1}" | sed -e 's,txz$,tar,'` ;;
|
||||
*)
|
||||
if [ -f "${file1}.gz" ]; then file2="${file1}.gz"
|
||||
elif [ -f "${file1}.bz2" ]; then file2="${file1}.bz2"
|
||||
elif [ -f "${file1}.lz" ]; then file2="${file1}.lz"
|
||||
elif [ -f "${file1}.xz" ]; then file2="${file1}.xz"
|
||||
if [ -f "${file1}.bz2" ] ; then file2="${file1}.bz2"
|
||||
elif [ -f "${file1}.gz" ] ; then file2="${file1}.gz"
|
||||
elif [ -f "${file1}.lz" ] ; then file2="${file1}.lz"
|
||||
elif [ -f "${file1}.xz" ] ; then file2="${file1}.xz"
|
||||
else
|
||||
echo "$0: Compressed version of ${file1} not found; use --help for usage." 1>&2
|
||||
exit 1
|
||||
|
@ -119,28 +119,22 @@ fi
|
|||
prog1=
|
||||
prog2=
|
||||
bindir=`echo "$0" | sed -e 's,[^/]*$,,'`
|
||||
if [ -f "${file1}" ]; then
|
||||
if [ -f "${file1}" ] ; then
|
||||
prog_name=`"${bindir}"zutils -t -- "${file1}"`
|
||||
case "${prog_name}" in
|
||||
gzip) prog1=gzip ;;
|
||||
bzip2) prog1=bzip2 ;;
|
||||
lzip) prog1=lzip ;;
|
||||
xz) prog1=xz ;;
|
||||
bzip2 | gzip | lzip | xz) prog1=${prog_name} ;;
|
||||
esac
|
||||
fi
|
||||
if [ -f "${file2}" ]; then
|
||||
if [ -f "${file2}" ] ; then
|
||||
prog_name=`"${bindir}"zutils -t -- "${file2}"`
|
||||
case "${prog_name}" in
|
||||
gzip) prog2=gzip ;;
|
||||
bzip2) prog2=bzip2 ;;
|
||||
lzip) prog2=lzip ;;
|
||||
xz) prog2=xz ;;
|
||||
bzip2 | gzip | lzip | xz) prog2=${prog_name} ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
retval=0
|
||||
if [ -n "${prog1}" ]; then
|
||||
if [ -n "${prog2}" ]; then
|
||||
if [ -n "${prog1}" ] ; then
|
||||
if [ -n "${prog2}" ] ; then
|
||||
tmp_file=`mktemp "${TMPDIR:-/tmp}"/zdiff.XXXXXXXXXX` || {
|
||||
echo 'cannot create a temporary file' 1>&2
|
||||
exit 1
|
||||
|
@ -154,7 +148,7 @@ if [ -n "${prog1}" ]; then
|
|||
retval=$?
|
||||
fi
|
||||
else
|
||||
if [ -n "${prog2}" ]; then
|
||||
if [ -n "${prog2}" ] ; then
|
||||
${prog2} -cdfq -- "${file2}" | ${diff_prog} ${args} -- "${file1}" -
|
||||
retval=$?
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue