#!/bin/sh

script_name=`basename $0`

usage="Usage: $script_name manpage manpage ..."

if test $# -eq 0 ; then echo $usage ; exit 1 ; fi

catch_sigs="2 15"

#
# We can't take any interrupts while processing the manpages
#
trap 'interrupt_occured=yes' $catch_sigs

temp_file=/tmp/tmp.$$

for i in $*
do
	rm -f $temp_file
	sed 's/[.]SB/.B/' $i > $temp_file         # do the replacement
	cmp -s $i $temp_file                      # and compare
	if test $? -ne 0 ; then                   # if not equal, then
		mv $i $i.orig && mv $temp_file $i      # save original, and move
	fi                                        # the other one in its place
	rm -f $temp_file
	if test "$interrupt_occured" = "yes" ; then
		echo "$script_name: Interrupt: quiting"
		exit 1
	fi
done

