: command file to setup/run/cleanup editor component of exercise package
: Martin Tuori, DCIEM, Toronto, Feb 1982.

COMM=$1
COUNT=$2
CHECK=$3

case $COMM in
	se*)
:		setup
		ed - input < script; mv output compare
		while test $COUNT != 0
		do
			mkdir ed$COUNT
:			echo ed$COUNT made
			COUNT=`expr $COUNT - 1`
		done
		;;
	cl*)
:		cleanup
		while test $COUNT != 0
		do
			rm ed$COUNT/*
			rmdir ed$COUNT
:			echo ed$COUNT emptied and removed
			COUNT=`expr $COUNT - 1`
		done
		;;
	ru*)
:		run
		case $CHECK in
		check)
			while test $COUNT != 0
			do
				(cd ed$COUNT; ed - ../input<../script; cmp output ../compare)&
:				echo ed$COUNT running with check
				COUNT=`expr $COUNT - 1`
			done
			wait
			;;
		*)
			while test $COUNT != 0
			do
				(cd ed$COUNT; ed - ../input<../script)&
:				echo ed$COUNT running without check
				COUNT=`expr $COUNT - 1`
			done
			wait
		;;
		esac
		;;
	*)
		echo command $COMM not understood, try again.
		;;
esac
