#!/bin/sh
# Compare two CG files using energy as a key

usage='comparecg [-g] [-f font] [-b|-i|-w|-W|-D] [-N name] cg-file1 cg-file2'

diff="diff"

if [ $# = 0 ]
then
   echo usage
   exit 1
else
	while getopts bgitwf:N:WD i
	do
		case $i in
		b|i|w|W|D)	
			diffargs=$diffargs" -"$i;;
		g)	diff="gdiff";;
		f|N)	diffargs=$diffargs" -"$i" "$OPTARG;;
		*|\?)	echo "Unrecognized option: $i"
			echo $usage
			exit 2
			;;
		esac
	done
	shift `expr $OPTIND - 1`
fi

pid=$$
cmploop $1 | grep '#' | cut -c9- | sort | sortn - foo.1.${pid} 17 12
cmploop $2 | grep '#' | cut -c9- | sort | sortn - foo.2.${pid} 17 12
$diff $diffargs foo.1.${pid} foo.2.${pid}
rm foo.1.${pid}
rm foo.2.${pid}
