# Update.man
# Update COHERENT man pages
# Must be user "bin" to run this

if [ `whoami` != "bin" ] ; then
	echo "Sorry, only user 'bin' can run this program"
	exit
fi

INPUT=/v/doc/coherent
OUTPUT=/usr/man
lastupdate=$INPUT/man.pages/updated.coh

rm $OUTPUT/man.index.new
cd $INPUT/lx

# process the first batch
echo ".ds OD COHERENT.1" > /tmp/coherent.r
for i in _ a b c d e f g h i j k l
do
	for j in `find . -type f -newer $lastupdate -name '$i*'`
	do
		nroff -x -mcohman $INPUT/top.r /tmp/coherent.r $j \
			> $OUTPUT/COHERENT.1/$j 2>> $OUTPUT/man.index.new
	done
done

# process the second batch
echo ".ds OD COHERENT.2" > /tmp/coherent.r
for i in m n o p q r s t u v w x y z
do
	for j in `find . -type f -newer $lastupdate -name '$i*'`
	do
		nroff -x -mcohman $INPUT/top.r /tmp/coherent.r $j \
			> $OUTPUT/COHERENT.2/$j 2>> $OUTPUT/man.index.new
	done
done

rm /tmp/coherent.r
touch $lastupdate
