diff options
author | Julian Seward <jseward@acm.org> | 2001-12-30 22:13:13 +0100 |
---|---|---|
committer | Julian Seward <jseward@acm.org> | 2001-12-30 22:13:13 +0100 |
commit | 099d844292f60f9d58914da29e5773204dc55e7a (patch) | |
tree | 04bdb38dbcd894d6fdbbc3253e216d029cade5c6 /bzdiff | |
parent | 795b859eee96c700e8f3c3fe68e6a9a39d95797c (diff) | |
download | bzip2-099d844292f60f9d58914da29e5773204dc55e7a.tar.gz bzip2-099d844292f60f9d58914da29e5773204dc55e7a.tar.bz2 bzip2-099d844292f60f9d58914da29e5773204dc55e7a.zip |
bzip2-1.0.2bzip2-1.0.2
Diffstat (limited to 'bzdiff')
-rw-r--r-- | bzdiff | 76 |
1 files changed, 76 insertions, 0 deletions
@@ -0,0 +1,76 @@ | |||
1 | #!/bin/sh | ||
2 | # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh | ||
3 | |||
4 | # Bzcmp/diff wrapped for bzip2, | ||
5 | # adapted from zdiff by Philippe Troin <phil@fifi.org> for Debian GNU/Linux. | ||
6 | |||
7 | # Bzcmp and bzdiff are used to invoke the cmp or the diff pro- | ||
8 | # gram on compressed files. All options specified are passed | ||
9 | # directly to cmp or diff. If only 1 file is specified, then | ||
10 | # the files compared are file1 and an uncompressed file1.gz. | ||
11 | # If two files are specified, then they are uncompressed (if | ||
12 | # necessary) and fed to cmp or diff. The exit status from cmp | ||
13 | # or diff is preserved. | ||
14 | |||
15 | PATH="/usr/bin:$PATH"; export PATH | ||
16 | prog=`echo $0 | sed 's|.*/||'` | ||
17 | case "$prog" in | ||
18 | *cmp) comp=${CMP-cmp} ;; | ||
19 | *) comp=${DIFF-diff} ;; | ||
20 | esac | ||
21 | |||
22 | OPTIONS= | ||
23 | FILES= | ||
24 | for ARG | ||
25 | do | ||
26 | case "$ARG" in | ||
27 | -*) OPTIONS="$OPTIONS $ARG";; | ||
28 | *) if test -f "$ARG"; then | ||
29 | FILES="$FILES $ARG" | ||
30 | else | ||
31 | echo "${prog}: $ARG not found or not a regular file" | ||
32 | exit 1 | ||
33 | fi ;; | ||
34 | esac | ||
35 | done | ||
36 | if test -z "$FILES"; then | ||
37 | echo "Usage: $prog [${comp}_options] file [file]" | ||
38 | exit 1 | ||
39 | fi | ||
40 | tmp=`tempfile -d /tmp -p bz` || { | ||
41 | echo 'cannot create a temporary file' >&2 | ||
42 | exit 1 | ||
43 | } | ||
44 | set $FILES | ||
45 | if test $# -eq 1; then | ||
46 | FILE=`echo "$1" | sed 's/.bz2$//'` | ||
47 | bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE" | ||
48 | STAT="$?" | ||
49 | |||
50 | elif test $# -eq 2; then | ||
51 | case "$1" in | ||
52 | *.bz2) | ||
53 | case "$2" in | ||
54 | *.bz2) | ||
55 | F=`echo "$2" | sed 's|.*/||;s|.bz2$||'` | ||
56 | bzip2 -cdfq "$2" > $tmp | ||
57 | bzip2 -cdfq "$1" | $comp $OPTIONS - $tmp | ||
58 | STAT="$?" | ||
59 | /bin/rm -f $tmp;; | ||
60 | |||
61 | *) bzip2 -cdfq "$1" | $comp $OPTIONS - "$2" | ||
62 | STAT="$?";; | ||
63 | esac;; | ||
64 | *) case "$2" in | ||
65 | *.bz2) | ||
66 | bzip2 -cdfq "$2" | $comp $OPTIONS "$1" - | ||
67 | STAT="$?";; | ||
68 | *) $comp $OPTIONS "$1" "$2" | ||
69 | STAT="$?";; | ||
70 | esac;; | ||
71 | esac | ||
72 | exit "$STAT" | ||
73 | else | ||
74 | echo "Usage: $prog [${comp}_options] file [file]" | ||
75 | exit 1 | ||
76 | fi | ||