#!/bin/sh
#
# $Id: odc-ci,v 2.1 1998/10/30 23:49:49 diego Exp $
#
if [ "$1" = "" ] ; then
    echo "usage: `basename $0` file(s)"
    echo
    echo "This script is a wrapper around RCS's 'ci' command. For each file to"
    echo "check in it opens an editor to make it easier to add log entries."
    exit 1
fi

if [ "$EDITOR" = "" ] ; then
	EDITOR=vi
fi

for i in $* ; do
    #
    # Check if we even have to check in the file
    #
    rcsdiff -q $i >/dev/null 2>&1

    if [ $? -gt 0 ] ; then
	logfile=$i.log

	echo "%%%" 						>>$logfile
	echo "%%% The contents of this file will be used as the">>$logfile
	echo "%%% log entry for the source file $i."		>>$logfile
	echo "%%%"						>>$logfile
	echo "%%% IMPORTANT: All the lines starting with %%%"	>>$logfile
	echo "%%%            will be removed!"			>>$logfile
	echo "%%%"						>>$logfile

	$EDITOR $logfile

	printf "Press <Enter> to check in $i and continue or <Ctrl-C> to abort. "
	read ans

	cat $logfile | grep -v '^%%%' | ci -t-"" -u $i
	rm -f $logfile
    fi
done
