# duplicate account stuff
#
trap  ""  2 3 15

user=`who am i | sed "s/ .*//"`
if [ -z "$user" ]	# 8-character bug hack
then
	user=$LOGNAME
fi
if [ "$user" = "$1" ]
then	other=$2
elif [ "$user" = "$2" ]
then	other=$1
else
	mail sp <<DupeFiX
Subject: Duplicate: $user ($1 $2)

$user did not match either "$1" or "$2"!
DupeFiX
	exit
fi

itema="keep \"$user\" and delete \"$other\""
itemb="keep \"$other\" and delete \"$user\""
itemc="keep \"$other\", but with the password from \"$user\", and delete \"$user\""
ans=""
while [ -z "$ans" ]
do
	echo
	echo "You seem to have a duplicate account named \"$other\"."
	echo "Do you want to:"
	echo
	echo "  A) $itema"
	echo "  B) $itemb"
	echo "  C) $itemc"
	echo
	echo "your choice: \c"
	read ans
	case $ans in
	a|A)	doit=$itema;;
	b|B)	doit=$itemb;;
	c|C)	doit=$itemc;;
	*)	ans=""
		echo
		echo "Please try that again...";;
	esac
done

mail sp <<DupeFiX
Subject: Duplicate: $user ($1 $2)

$user wants to $doit.
DupeFiX

trap 2 3 15