Chris@4: #!/bin/sh Chris@4: # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh Chris@4: Chris@4: # Bzcmp/diff wrapped for bzip2, Chris@4: # adapted from zdiff by Philippe Troin for Debian GNU/Linux. Chris@4: Chris@4: # Bzcmp and bzdiff are used to invoke the cmp or the diff pro- Chris@4: # gram on compressed files. All options specified are passed Chris@4: # directly to cmp or diff. If only 1 file is specified, then Chris@4: # the files compared are file1 and an uncompressed file1.gz. Chris@4: # If two files are specified, then they are uncompressed (if Chris@4: # necessary) and fed to cmp or diff. The exit status from cmp Chris@4: # or diff is preserved. Chris@4: Chris@4: PATH="/usr/bin:/bin:$PATH"; export PATH Chris@4: prog=`echo $0 | sed 's|.*/||'` Chris@4: case "$prog" in Chris@4: *cmp) comp=${CMP-cmp} ;; Chris@4: *) comp=${DIFF-diff} ;; Chris@4: esac Chris@4: Chris@4: OPTIONS= Chris@4: FILES= Chris@4: for ARG Chris@4: do Chris@4: case "$ARG" in Chris@4: -*) OPTIONS="$OPTIONS $ARG";; Chris@4: *) if test -f "$ARG"; then Chris@4: FILES="$FILES $ARG" Chris@4: else Chris@4: echo "${prog}: $ARG not found or not a regular file" Chris@4: exit 1 Chris@4: fi ;; Chris@4: esac Chris@4: done Chris@4: if test -z "$FILES"; then Chris@4: echo "Usage: $prog [${comp}_options] file [file]" Chris@4: exit 1 Chris@4: fi Chris@4: tmp=`mktemp ${TMPDIR:-/tmp}/bzdiff.XXXXXXXXXX` || { Chris@4: echo 'cannot create a temporary file' >&2 Chris@4: exit 1 Chris@4: } Chris@4: set $FILES Chris@4: if test $# -eq 1; then Chris@4: FILE=`echo "$1" | sed 's/.bz2$//'` Chris@4: bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE" Chris@4: STAT="$?" Chris@4: Chris@4: elif test $# -eq 2; then Chris@4: case "$1" in Chris@4: *.bz2) Chris@4: case "$2" in Chris@4: *.bz2) Chris@4: F=`echo "$2" | sed 's|.*/||;s|.bz2$||'` Chris@4: bzip2 -cdfq "$2" > $tmp Chris@4: bzip2 -cdfq "$1" | $comp $OPTIONS - $tmp Chris@4: STAT="$?" Chris@4: /bin/rm -f $tmp;; Chris@4: Chris@4: *) bzip2 -cdfq "$1" | $comp $OPTIONS - "$2" Chris@4: STAT="$?";; Chris@4: esac;; Chris@4: *) case "$2" in Chris@4: *.bz2) Chris@4: bzip2 -cdfq "$2" | $comp $OPTIONS "$1" - Chris@4: STAT="$?";; Chris@4: *) $comp $OPTIONS "$1" "$2" Chris@4: STAT="$?";; Chris@4: esac;; Chris@4: esac Chris@4: exit "$STAT" Chris@4: else Chris@4: echo "Usage: $prog [${comp}_options] file [file]" Chris@4: exit 1 Chris@4: fi