#!/bin/sh progname=$0 version=1.1.0 usage="\ Usage: $progname file A simple shell script launches gtkdiff(1) for RCS(1) files. This intends to be compatible with rcsdiff(1). -r N, --revision N specifies revision numbers. space between -r and N can be omitted. The meaning follows rcsdiff(1). -3, --diff3 Use diff3(1). -h, --help print this help and exit -v, --version print version information and exit Example: \$ gtkdiff-rcs GnewsAlert.c ( diff with latest ) \$ gtkdiff-rcs -r1.1 GnewsAlert.c ( diff with revision 1.1 ) \$ gtkdiff-rcs -r1.1 -r1.2 GnewsAlert.c ( diff between revisions 1.1 and 1.2 ) \$ gtkdiff-rcs -3 -r1.1 GnewsAlert.c ( diff3 among current, latest and revision 1.1 ) \$ gtkdiff-rcs -3 -r1.1 -r1.2 GnewsAlert.c ( diff3 among current, and revisions 1.1 and 1.2 ) \$ gtkdiff-rcs -r1.1 -r1.2 -r1.3 GnewsAlert.c ( diff3 among revisions 1.1, 1.2 and 1.3 ) " # Command path CO=@CO@ RM=@RM@ GTKDIFF=@prefix@/bin/gtkdiff # Temporary files information : ${TMPDIR=/tmp} TMP_SUFFIX=@gtkdiff$$ TMP_REV1_FILE= TMP_REV2_FILE= TMP_REV3_FILE= # variables rev1= rev2= rev3= use_diff3=0 rm_tmpfiles () { [ -n "$TMP_REV1_FILE" -a -f $TMP_REV1_FILE ] && $RM -f $TMP_REV1_FILE [ -n "$TMP_REV2_FILE" -a -f $TMP_REV2_FILE ] && $RM -f $TMP_REV2_FILE [ -n "$TMP_REV3_FILE" -a -f $TMP_REV3_FILE ] && $RM -f $TMP_REV3_FILE } finalize () { rm_tmpfiles exit 1 } trap finalize INT QUIT HUP TERM # # Option processing # while [ "$1" != "" ] do case "$1" in -r | --revision) shift test $# -eq 0 && { echo "$usage"; exit 0; } [ -z "$rev1" ] && { rev1="$1"; shift; continue; } [ -z "$rev2" ] && { rev2="$1"; shift; continue; } [ -z "$rev3" ] && rev3="$1";; -r*) [ -z "$rev1" ] && { rev1=`expr $1 : '-r\(.*\)'`; shift; continue; } [ -z "$rev2" ] && { rev2=`expr $1 : '-r\(.*\)'`; shift; continue; } [ -z "$rev3" ] && rev3=`expr $1 : '-r\(.*\)'`;; -3 | --diff3) use_diff3=1;; -h | --help) echo "$usage"; exit 0;; -v | --version | --v*) echo "$progname $version"; exit 0;; --) # Stop option processing. shift; break ;; *) break ;; esac shift done if [ -z "$1" ] then echo "$usage" exit 1 fi # # Check necessary files # if [ ! -x "$GTKDIFF" ] then echo "Warning:" echo "You can't execute $GTKDIFF." echo "Are you sure you have GtkDiff installed ?" exit 0 fi if [ ! -x "$CO" ] then echo "Warning:" echo "You can't execute $CO." echo "Are you sure you have RCS installed ?" exit 0 fi if [ ! -f "$1" ] then echo "Warning:" echo "$1 not found" exit 0 fi # # Create temporary revision files # TMP_REV1_FILE=$TMPDIR/`basename ${1}`"("${rev1}")"${TMP_SUFFIX} TMP_REV2_FILE=$TMPDIR/`basename ${1}`"("${rev2}")"${TMP_SUFFIX} TMP_REV3_FILE=$TMPDIR/`basename ${1}`"("${rev3}")"${TMP_SUFFIX} if [ -n "$rev1" ] then $CO -p$rev1 $1 > $TMP_REV1_FILE else TMP_REV1_FILE=$TMPDIR/`basename ${1}`"("latest")"${TMP_SUFFIX} $CO -p $1 > $TMP_REV1_FILE $GTKDIFF $TMP_REV1_FILE $1 rm_tmpfiles exit 0 fi if [ -n "$rev2" ] then $CO -p$rev2 $1 > $TMP_REV2_FILE else if [ $use_diff3 -eq 0 ]; then $GTKDIFF $TMP_REV1_FILE $1 rm_tmpfiles exit 0 else TMP_REV2_FILE=$TMPDIR/`basename ${1}`"("latest")"${TMP_SUFFIX} $CO -p $1 > $TMP_REV2_FILE $GTKDIFF $TMP_REV1_FILE $TMP_REV2_FILE $1 rm_tmpfiles exit 0 fi fi if [ -n "$rev3" ] then $CO -p$rev3 $1 > $TMP_REV3_FILE $GTKDIFF $TMP_REV1_FILE $TMP_REV2_FILE $TMP_REV3_FILE else if [ $use_diff3 -eq 0 ]; then $GTKDIFF $TMP_REV1_FILE $TMP_REV2_FILE else $GTKDIFF $TMP_REV1_FILE $TMP_REV2_FILE $1 fi fi rm_tmpfiles exit 0