User:Scsbot/formtools/formselect

From Wiktionary, the free dictionary
Jump to navigation Jump to search
tag=$1
formname=$2

td=td$tag

if test ! -d $td
then
	echo "$tag not set up" >&2
	exit 1
fi

if test ! -f $td/.toc
then
	echo "$tag: no TOC" >&2
	exit 1
fi

id=`awk "\\$2 == \\"$formname\\" {print \\$1}" $td/.toc`

if test -z "$id"
then
	echo "$tag: form $formname not found" >&2
	exit 1
fi

if test `echo "$id" | wc -l` -gt 1
then
	echo "$tag: form $formname: multiple matches" >&2
	exit 1
fi

echo "$id" > $td/.cur

exit 0