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

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

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