annotate src/bzip2-1.0.6/bzdiff @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents e13257ea84a4
children
rev   line source
Chris@4 1 #!/bin/sh
Chris@4 2 # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
Chris@4 3
Chris@4 4 # Bzcmp/diff wrapped for bzip2,
Chris@4 5 # adapted from zdiff by Philippe Troin <phil@fifi.org> for Debian GNU/Linux.
Chris@4 6
Chris@4 7 # Bzcmp and bzdiff are used to invoke the cmp or the diff pro-
Chris@4 8 # gram on compressed files. All options specified are passed
Chris@4 9 # directly to cmp or diff. If only 1 file is specified, then
Chris@4 10 # the files compared are file1 and an uncompressed file1.gz.
Chris@4 11 # If two files are specified, then they are uncompressed (if
Chris@4 12 # necessary) and fed to cmp or diff. The exit status from cmp
Chris@4 13 # or diff is preserved.
Chris@4 14
Chris@4 15 PATH="/usr/bin:/bin:$PATH"; export PATH
Chris@4 16 prog=`echo $0 | sed 's|.*/||'`
Chris@4 17 case "$prog" in
Chris@4 18 *cmp) comp=${CMP-cmp} ;;
Chris@4 19 *) comp=${DIFF-diff} ;;
Chris@4 20 esac
Chris@4 21
Chris@4 22 OPTIONS=
Chris@4 23 FILES=
Chris@4 24 for ARG
Chris@4 25 do
Chris@4 26 case "$ARG" in
Chris@4 27 -*) OPTIONS="$OPTIONS $ARG";;
Chris@4 28 *) if test -f "$ARG"; then
Chris@4 29 FILES="$FILES $ARG"
Chris@4 30 else
Chris@4 31 echo "${prog}: $ARG not found or not a regular file"
Chris@4 32 exit 1
Chris@4 33 fi ;;
Chris@4 34 esac
Chris@4 35 done
Chris@4 36 if test -z "$FILES"; then
Chris@4 37 echo "Usage: $prog [${comp}_options] file [file]"
Chris@4 38 exit 1
Chris@4 39 fi
Chris@4 40 tmp=`mktemp ${TMPDIR:-/tmp}/bzdiff.XXXXXXXXXX` || {
Chris@4 41 echo 'cannot create a temporary file' >&2
Chris@4 42 exit 1
Chris@4 43 }
Chris@4 44 set $FILES
Chris@4 45 if test $# -eq 1; then
Chris@4 46 FILE=`echo "$1" | sed 's/.bz2$//'`
Chris@4 47 bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE"
Chris@4 48 STAT="$?"
Chris@4 49
Chris@4 50 elif test $# -eq 2; then
Chris@4 51 case "$1" in
Chris@4 52 *.bz2)
Chris@4 53 case "$2" in
Chris@4 54 *.bz2)
Chris@4 55 F=`echo "$2" | sed 's|.*/||;s|.bz2$||'`
Chris@4 56 bzip2 -cdfq "$2" > $tmp
Chris@4 57 bzip2 -cdfq "$1" | $comp $OPTIONS - $tmp
Chris@4 58 STAT="$?"
Chris@4 59 /bin/rm -f $tmp;;
Chris@4 60
Chris@4 61 *) bzip2 -cdfq "$1" | $comp $OPTIONS - "$2"
Chris@4 62 STAT="$?";;
Chris@4 63 esac;;
Chris@4 64 *) case "$2" in
Chris@4 65 *.bz2)
Chris@4 66 bzip2 -cdfq "$2" | $comp $OPTIONS "$1" -
Chris@4 67 STAT="$?";;
Chris@4 68 *) $comp $OPTIONS "$1" "$2"
Chris@4 69 STAT="$?";;
Chris@4 70 esac;;
Chris@4 71 esac
Chris@4 72 exit "$STAT"
Chris@4 73 else
Chris@4 74 echo "Usage: $prog [${comp}_options] file [file]"
Chris@4 75 exit 1
Chris@4 76 fi