#!/bin/sh
#
#	@(#)i.ttmapsdir 1.1     97/11/06 SMI;
#
# Copyright (c) 1994 by Sun Microsystems, Inc.
#

PATH="/usr/bin:/usr/sbin:${PATH}"
export PATH

while read src dest
do
	if [ ! -f $dest ] ; then
		cp $src $dest
	else
		cat $dest | sed -e '1d' > /tmp/$$ttmaps.dir
		cat $src  | sed -e '1d' > /tmp/$$ttmaps.dir.add
		diff -w /tmp/$$ttmaps.dir /tmp/$$ttmaps.dir.add | \
		grep '^>' > /dev/null && (
			count=`grep '^FILENAME' /tmp/$$ttmaps.dir \
					/tmp/$$ttmaps.dir.add | wc -l`
			echo $count > $dest
			cat /tmp/$$ttmaps.dir /tmp/$$ttmaps.dir.add >> $dest
			rm /tmp/$$ttmaps.dir /tmp/$$ttmaps.dir.add
		)
	fi
done

exit 0
