2 # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
4 # Zcmp and zdiff are used to invoke the cmp or the diff pro-
5 # gram on compressed files. All options specified are passed
6 # directly to cmp or diff. If only 1 file is specified, then
7 # the files compared are file1 and an uncompressed file1.gz.
8 # If two files are specified, then they are uncompressed (if
9 # necessary) and fed to cmp or diff. The exit status from cmp
10 # or diff is preserved.
12 PATH="BINDIR:$PATH"; export PATH
14 *cmp) prog=cmp ; cmp='${CMP-cmp}' ;;
15 *) prog=diff; cmp='${DIFF-diff}';;
19 version="z$prog (gzip) @VERSION@
20 Copyright (C) 2006 Free Software Foundation, Inc.
21 This is free software. You may redistribute copies of it under the terms of
22 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
23 There is NO WARRANTY, to the extent permitted by law.
25 Written by Jean-loup Gailly."
27 usage="Usage: z$prog [OPTION]... FILE1 [FILE2]
28 Compare FILE1 to FILE2, using their uncompressed contents if they are
29 compressed. If FILE2 is omitted, compare FILE1 to the uncompressed
30 contents of FILE1.gz. Do comparisons like '$prog' does.
32 OPTIONs are the same as for '$prog'.
34 Report bugs to <bug-gzip@gnu.org>."
39 --h*) echo "$usage" || exit 2; exit;;
40 --v*) echo "$version" || exit 2; exit;;
42 -*\'*) echo >&2 "$prog: $1: option contains apostrophe"; exit 2;;
43 -?*) cmp="$cmp '$1'"; shift;;
51 test "X$file" = X- || <"$file" || exit 2
54 if test $# -eq 1; then
56 *[-.]gz* | *[-.][zZ] | *.t[ga]z)
57 FILE=`expr "X$1" : 'X\(.*\)[-.][zZtga]*$'`
58 gzip -cd -- "$1" | eval "$cmp" - '"$FILE"';;
60 echo >&2 "$prog: $1: unknown compressed file extension"
63 elif test $# -eq 2; then
65 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
67 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
68 if test "$1$2" = --; then
69 gzip -cdfq - | eval "$cmp" - -
71 # Reject Solaris 8's buggy /bin/bash 2.03.
73 (echo X | eval "$cmp0" /dev/fd/3 - >/dev/null 2>&1) \
78 eval "$cmp" /dev/fd/3 -) 3<&0
80 F=`expr "/$2" : '.*/\(.*\)[-.][zZtga]*$'` || F=$prog
83 test -n "$tmp" && rm -f "$tmp"
86 if type mktemp >/dev/null 2>&1; then
87 tmp=`mktemp -t -- "$F.XXXXXX"` || exit
90 tmp=${TMPDIR-/tmp}/$F.$$
92 gzip -cdfq -- "$2" > "$tmp" || exit
93 gzip -cdfq -- "$1" | eval "$cmp" - '"$tmp"'
95 rm -f "$tmp" || STAT=2
96 trap - HUP INT PIPE TERM 0
99 *) gzip -cdfq -- "$1" | eval "$cmp" - '"$2"';;
102 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
103 gzip -cdfq -- "$2" | eval "$cmp" '"$1"' -;;
104 *) eval "$cmp" '"$1"' '"$2"';;