3 # $NetBSD: zdiff,v 1.3 2004/03/29 10:01:00 wiz Exp $
4 # $OpenBSD: zdiff,v 1.2 2003/07/29 07:42:44 otto Exp $
7 # Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
9 # Permission to use, copy, modify, and distribute this software for any
10 # purpose with or without fee is hereby granted, provided that the above
11 # copyright notice and this permission notice appear in all copies.
13 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 # Sponsored in part by the Defense Advanced Research Projects
22 # Agency (DARPA) and Air Force Research Laboratory, Air Force
23 # Materiel Command, USAF, under agreement number F39502-99-1-0512.
27 # Set $prog based on $0
34 USAGE="usage: z$prog [options] file1 [file2]"
36 # Pull out any command line flags so we can pass them to diff/cmp
37 # XXX - assumes there is no optarg
39 while test $# -ne 0; do
56 # One file given, compare compressed to uncompressed
68 *) echo "z$prog: unknown suffix" 1>&2
71 gzip -cdfq "$1" | $prog $flags - "$files"
73 elif [ $# -eq 2 ]; then
74 # Two files given, compare the two uncompressing as needed
76 *[._-][Zz]|*[._-]gz|*.t[ag]z)
85 *[._-][Zz]|*[._-]gz|*.t[ag]z)
86 if [ "$files" = "-" ]; then
87 tmp=`mktemp -t z$prog.XXXXXXXXXX` || exit 1
88 trap "rm -f $tmp" 0 1 2 3 13 15
89 gzip -cdfq "$2" > $tmp
100 if [ -n "$filt" ]; then
101 $filt | $prog $flags $files