#! /bin/sh

if [ "x$1" = "x" ]; then
	echo "Usage: modpath your-t3xdir/ (note trailing slash!)"
	echo "       modpath reset"
	exit 1
fi

if [ "$1" = "reset" ]; then
	for x in targets/cg*.t; do
		if [ -f $x.orig ]; then
			mv -f $x.orig $x
		fi
	done
	exit 0
fi

(cd targets; for cg in cg*.t; do
	if [ ! -f $cg.orig ]; then
		cp $cg $cg.orig
	fi
	sed -e "s|/usr/local/t3x/0/|$1|" <$cg.orig >$cg
done)
