3 # $NetBSD: zdiff,v 1.2 2003/12/28 12:43:43 wiz Exp $
4 # $DragonFly: src/usr.bin/gzip/zdiff,v 1.1 2004/10/26 11:19:31 joerg Exp $
5 # $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.
26 # Set $prog based on $0
33 USAGE
="usage: z$prog [options] file1 [file2]"
35 # Pull out any command line flags so we can pass them to diff/cmp
36 # XXX - assumes there is no optarg
38 while test $# -ne 0; do
55 # One file given, compare compressed to uncompressed
67 *) echo "z$prog: unknown suffix" 1>&2
70 gzip -cdfq "$1" |
$prog $flags - "$files"
72 elif [ $# -eq 2 ]; then
73 # Two files given, compare the two uncompressing as needed
75 *[._-
][Zz
]|
*[._-
]gz|
*.t
[ag
]z
)
84 *[._-
][Zz
]|
*[._-
]gz|
*.t
[ag
]z
)
85 if [ "$files" = "-" ]; then
86 tmp
=`mktemp -t z$prog.XXXXXXXXXX` ||
exit 1
87 trap "rm -f $tmp" 0 1 2 3 13 15
88 gzip -cdfq "$2" > $tmp
99 if [ -n "$filt" ]; then
100 $filt |
$prog $flags $files