source: Daodan/MinGW/msys/1.0/bin/zdiff@ 1046

Last change on this file since 1046 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 4.3 KB
RevLine 
[1046]1#!/bin/sh
2# sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
3
4# Copyright (C) 1998, 2002, 2006, 2007 Free Software Foundation
5# Copyright (C) 1993 Jean-loup Gailly
6
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License along
18# with this program; if not, write to the Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21PATH=${GZIP_BINDIR-'/usr/bin'}:$PATH
22
23case $1 in
24 --__cmp) shift
25 prog=cmp; cmp='${CMP-cmp}' ;;
26 *) prog=diff; cmp='${DIFF-diff}';;
27esac
28
29version="z$prog (gzip) 1.3.12
30Copyright (C) 2007 Free Software Foundation, Inc.
31This is free software. You may redistribute copies of it under the terms of
32the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
33There is NO WARRANTY, to the extent permitted by law.
34
35Written by Jean-loup Gailly."
36
37usage="Usage: $0 [OPTION]... FILE1 [FILE2]
38Compare FILE1 to FILE2, using their uncompressed contents if they are
39compressed. If FILE2 is omitted, compare FILE1 to the uncompressed
40contents of FILE1.gz. Do comparisons like '$prog' does.
41
42OPTIONs are the same as for '$prog'.
43
44Report bugs to <bug-gzip@gnu.org>."
45
46# sed script to escape all ' for the shell, and then (to handle trailing
47# newlines correctly) turn trailing X on last line into '.
48escape='
49 s/'\''/'\''\\'\'''\''/g
50 $s/X$/'\''/
51'
52
53while :; do
54 case $1 in
55 --h*) printf '%s\n' "$usage" || exit 2; exit;;
56 --v*) echo "$version" || exit 2; exit;;
57 --) shift; break;;
58 -*\'*) cmp="$cmp '"`printf '%sX\n' "$1" | sed "$escape"`;;
59 -?*) cmp="$cmp '$1'";;
60 *) break;;
61 esac
62 shift
63done
64cmp="$cmp --"
65
66for file
67do
68 test "X$file" = X- || <"$file" || exit 2
69done
70
71gzip_status=0
72exec 3>&1
73
74if test $# -eq 1; then
75 case $1 in
76 *[-.]gz* | *[-.][zZ] | *.t[ga]z)
77 FILE=`expr "X$1" : 'X\(.*\)[-.][zZtga]*$'`
78 gzip_status=$(
79 exec 4>&1
80 (gzip -cd -- "$1" 4>&-; echo $? >&4) 3>&- | eval "$cmp" - '"$FILE"' >&3
81 );;
82 *)
83 echo >&2 "$0: $1: unknown compressed file extension"
84 exit 2;;
85 esac
86elif test $# -eq 2; then
87 case "$1" in
88 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
89 case "$2" in
90 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
91 if test "$1$2" = --; then
92 gzip_status=$(
93 exec 4>&1
94 (gzip -cdfq - 4>&-; echo $? >&4) 3>&- |
95 eval "$cmp" - - >&3
96 )
97 elif
98 # Reject Solaris 8's buggy /bin/bash 2.03.
99 echo X |
100 (echo X | eval "$cmp" /dev/fd/5 - >/dev/null 2>&1) \
101 5<&0
102 then
103 gzip_status=$(
104 exec 4>&1
105 (gzip -cdfq -- "$1" 4>&-; echo $? >&4) 3>&- |
106 ( (gzip -cdfq -- "$2" 4>&-; echo $? >&4) 3>&- 5<&- </dev/null |
107 eval "$cmp" /dev/fd/5 - >&3) 5<&0
108 )
109 case $gzip_status in
110 *[1-9]*) gzip_status=1;;
111 *) gzip_status=0;;
112 esac
113 else
114 F=`expr "/$2" : '.*/\(.*\)[-.][zZtga]*$'` || F=$prog
115 tmp=
116 trap '
117 test -n "$tmp" && rm -f "$tmp"
118 (exit 2); exit 2
119 ' HUP INT PIPE TERM 0
120 if type mktemp >/dev/null 2>&1; then
121 tmp=`mktemp -t -- "$F.XXXXXX"` || exit 2
122 else
123 set -C
124 tmp=${TMPDIR-/tmp}/$F.$$
125 fi
126 gzip -cdfq -- "$2" > "$tmp" || exit 2
127 gzip_status=$(
128 exec 4>&1
129 (gzip -cdfq -- "$1" 4>&-; echo $? >&4) 3>&- |
130 eval "$cmp" - '"$tmp"' >&3
131 )
132 cmp_status=$?
133 rm -f "$tmp" || gzip_status=$?
134 trap - HUP INT PIPE TERM 0
135 (exit $cmp_status)
136 fi;;
137 *)
138 gzip_status=$(
139 exec 4>&1
140 (gzip -cdfq -- "$1" 4>&-; echo $? >&4) 3>&- |
141 eval "$cmp" - '"$2"' >&3
142 );;
143 esac;;
144 *) case "$2" in
145 *[-.]gz* | *[-.][zZ] | *.t[ga]z | -)
146 gzip_status=$(
147 exec 4>&1
148 (gzip -cdfq -- "$2" 4>&-; echo $? >&4) 3>&- |
149 eval "$cmp" '"$1"' - >&3
150 );;
151 *) eval "$cmp" '"$1"' '"$2"';;
152 esac;;
153 esac
154else
155 echo >&2 "$0: invalid number of operands; try \`$0 --help' for help"
156 exit 2
157fi
158
159cmp_status=$?
160test "$gzip_status" -eq 0 || exit 2
161exit $cmp_status
Note: See TracBrowser for help on using the repository browser.