view cds-commit @ 43:7fc785a79615

renamed penis to churn
author Josef "Jeff" Sipek <jsipek@cs.sunysb.edu>
date Sat, 05 May 2007 15:53:53 -0400
parents b5730de1f18d
children
line wrap: on
line source

#!/bin/bash

msg=""

while [ $# -gt 0 ]; do
	case "$1" in
		-m)
			msg="$2"
			shift
			shift
			;;
		*)
			break
			;;
	esac
done

if [ ! -z "$msg" ]; then
	# -m supplied, just use that instead of doing anything fancy
	cvs commit -m "$msg" "$@"
	exit $?
fi

if [ -z "$CDSEDITOR" ] ; then
	# no CDSEDITOR set, fall back to old behavior
	cvs commit "$@"
	exit $?
fi

CDSTMP="${TMPDIR-/tmp}/cdseditor.$RANDOM.$RANDOM.$RANDOM.$$"
(umask 077 && mkdir "$CDSTMP") || {
    echo "Could not create temporary directory! Exiting." 1>&2
    exit 1
}

cleanup_exit() {
    rm -rf "$CDSTMP"
}

# Remove temporary files even if we get interrupted
trap "cleanup_exit" 0 # normal exit
trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM

$CDSEDITOR $CDSTMP "$@"
RET=$?

if [ $RET -ne 1 ] ; then
	if [ $RET -eq 14 ] ; then
		echo "Nothing to commit"
		exit 0
	fi

	echo Aborted
	exit $RET
fi

cvs commit -F $CDSTMP/msg "$@"

exit $?