Blame bzlib-src/bzdiff

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