User:Scsbot/formtools/formsubmitbutton

From Wiktionary, the free dictionary
Jump to navigation Jump to search
:
# prepare to "push" a form submit button, by deleting the rest

tag=$1
buttonname=$2

rm="/bin/rm -f"

td=td$tag

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

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

formid=`cat $td/.cur`

if test ! -d $td/$formid -o ! -f $td/$formid/.toc
then
	echo "$tag: form not set up" >&2
	exit 1
fi

while read name type
do
	if test $type = "submit"
	then
		if test $name = $buttonname
		then	: # oughta record found
		else	$rm $td/$formid/$name
		fi
	fi
done < $td/$formid/.toc

# oughta complain if not found

exit 0