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 ; comp=${CMP-cmp} ;;
15 *) prog=diff; comp=${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>."
39 --h*) echo "$usage" || exit 2; exit;;
40 --v*) echo "$version" || exit 2; exit;;
42 -*) OPTIONS="$OPTIONS $ARG"; shift;;
47 echo "$prog: $file not found or not a regular file"
51 if test $# -eq 1; then
52 FILE=`echo "$1" | sed 's/[-.][zZtga]*$//'`
53 gzip -cd -- "$1" | $comp $OPTIONS - "$FILE"
55 elif test $# -eq 2; then
57 *[-.]gz* | *[-.][zZ] | *.t[ga]z)
59 *[-.]gz* | *[-.][zZ] | *.t[ga]z)
60 F=`echo "$2" | sed 's|.*/||;s|[-.][zZtga]*||'`
62 trap 'rm -f /tmp/"$F".$$; exit 2' HUP INT PIPE TERM 0
63 gzip -cdfq -- "$2" > /tmp/"$F".$$ || exit
64 gzip -cdfq -- "$1" | $comp $OPTIONS - /tmp/"$F".$$
66 /bin/rm -f /tmp/"$F".$$ || STAT=2
67 trap - HUP INT PIPE TERM 0
70 *) gzip -cdfq -- "$1" | $comp $OPTIONS - "$2";;
73 *[-.]gz* | *[-.][zZ] | *.t[ga]z)
74 gzip -cdfq -- "$2" | $comp $OPTIONS "$1" -;;
75 *) $comp $OPTIONS "$1" "$2";;