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 15PATH="/usr/bin:/bin:$PATH"; export PATH 16prog=`echo $0 | sed 's|.*/||'` 17case "$prog" in 18 *cmp) comp=${CMP-cmp} ;; 19 *) comp=${DIFF-diff} ;; 20esac 21 22OPTIONS= 23for ARG 24do 25 case "$ARG" in 26 -*) OPTIONS="$OPTIONS $ARG"; shift;; 27 *) break;; 28 esac 29done 30if [ $# -eq 0 ] || [ $# -gt 2 ]; then 31 echo "Usage: $prog [${comp}_options] file [file]" 32 exit 1 33fi 34if [ ! -f "$1" ]; then 35 echo "${prog}: $1 not found or not a regular file" 36 exit 1 37fi 38if [ $# -eq 2 ] && [ ! -f "$2" ]; then 39 echo "${prog}: $2 not found or not a regular file" 40 exit 1 41fi 42tmp=`mktemp ${TMPDIR:-/tmp}/bzdiff.XXXXXXXXXX` || { 43 echo 'cannot create a temporary file' >&2 44 exit 1 45} 46if test $# -eq 1; then 47 FILE=`echo "$1" | sed 's/.bz2$//'` 48 bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE" 49 STAT="$?" 50 51elif test $# -eq 2; then 52 case "$1" in 53 *.bz2) 54 case "$2" in 55 *.bz2) 56 F=`echo "$2" | sed 's|.*/||;s|.bz2$||'` 57 bzip2 -cdfq "$2" > $tmp 58 bzip2 -cdfq "$1" | $comp $OPTIONS - $tmp 59 STAT="$?" 60 /bin/rm -f $tmp;; 61 62 *) bzip2 -cdfq "$1" | $comp $OPTIONS - "$2" 63 STAT="$?";; 64 esac;; 65 *) case "$2" in 66 *.bz2) 67 bzip2 -cdfq "$2" | $comp $OPTIONS "$1" - 68 STAT="$?";; 69 *) $comp $OPTIONS "$1" "$2" 70 STAT="$?";; 71 esac;; 72 esac 73 exit "$STAT" 74fi 75