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}';;
18 version="z$prog (gzip) @VERSION@
19 Copyright (C) 2006 Free Software Foundation, Inc.
20 This is free software. You may redistribute copies of it under the terms of
21 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
22 There is NO WARRANTY, to the extent permitted by law.
24 Written by Jean-loup Gailly."
26 usage="Usage: z$prog [OPTION]... FILE1 [FILE2]
27 Compare FILE1 to FILE2, using their uncompressed contents if they are
28 compressed. If FILE2 is omitted, compare FILE1 to the uncompressed
29 contents of FILE1.gz. Do comparisons like '$prog' does.
31 OPTIONs are the same as for '$prog'.
33 Report bugs to <bug-gzip@gnu.org>."
38 --h*) echo "$usage" || exit 2; exit;;
39 --v*) echo "$version" || exit 2; exit;;
41 -*\'*) echo >&2 "$prog: $1: option contains apostrophe"; exit 2;;
42 -?*) cmp="$cmp '$1'"; shift;;
49 test "X$file" = X- || <"$file" || exit 2
52 if test $# -eq 1; then
54 *[-.]gz* | *[-.][zZ] | *.t[ga]z)
55 FILE=`expr "X$1" : 'X\(.*\)[-.][zZtga]*$'`
56 gzip -cd -- "$1" | eval "$cmp" - '"$FILE"';;
58 echo >&2 "$prog: $1: unknown compressed file extension"
61 elif test $# -eq 2; then
63 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
65 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
66 if test "$1$2" = --; then
67 gzip -cdfq - | eval "$cmp" - -
68 elif test -r /dev/fd/3 3</dev/null; then
71 eval "$cmp" /dev/fd/3 -) 3<&0
73 F=`expr "/$2" : '.*/\(.*\)[-.][zZtga]*$'` || F=$prog
76 test -n "$tmp" && rm -f "$tmp"
79 if type mktemp >/dev/null 2>&1; then
80 tmp=`mktemp -t -- "$F.XXXXXX"` || exit
83 tmp=${TMPDIR-/tmp}/$F.$$
85 gzip -cdfq -- "$2" > "$tmp" || exit
86 gzip -cdfq -- "$1" | eval "$cmp" - '"$tmp"'
88 rm -f "$tmp" || STAT=2
89 trap - HUP INT PIPE TERM 0
92 *) gzip -cdfq -- "$1" | eval "$cmp" - '"$2"';;
95 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
96 gzip -cdfq -- "$2" | eval "$cmp" '"$1"' -;;
97 *) eval "$cmp" '"$1"' '"$2"';;