#!/bin/sh
# $Id: RegressMan,v 1.1 2019/03/16 15:46:09 tom Exp $
mytemp=RegressMan$$
trap "rm -f $mytemp" EXIT INT QUIT HUP TERM
if [ ! -d MAN ] ; then
	mkdir MAN
fi
OPT=
while [ $# != 0 ]
do
	input=$1
	output=MAN/${input##*/}
	shift 1
	if [ ! -f "$input" ]
	then
		echo ".. skipping $input (not a file)"
		continue
	fi
	check=`head -n 1 $input | awk '{print $1}'`
	if [ "x$check" = "x.so" ]
	then
		echo ".. skipping $input (not interesting)"
		continue
	fi
	OPT=
	case $input in
	*.man|*.[1-9][A-Za-z]*)
		OPT=-man
		;;
	*.ms)
		OPT=-ms
		;;
	*)
		echo ".. skipping $input (unknown format)"
		continue
		;;
	esac
	echo "** processing $OPT $input"
	nroff $OPT $input >$mytemp
	if [ -f $output ]
	then
		diff -u -b $mytemp $output && echo ".. unchanged"
	else
		cat $mytemp >$output
	fi
done
