moth/cmd/mothd/testdata/testpiler.sh

41 lines
753 B
Bash
Raw Normal View History

#! /bin/sh -e
2020-08-28 14:05:32 -06:00
fail () {
echo "$@" 1>&2
exit 1
}
case "$ACTION:$CAT:$POINTS" in
2020-09-04 15:29:06 -06:00
inventory::)
cat <<EOT
{
"pategory": [1, 2, 3, 4, 5, 10, 20, 300],
"nealegory": [1, 3, 2]
}
EOT
;;
open:*:*)
case "$CAT:$POINTS:$FILENAME" in
*:*:moo.txt)
echo "Moo."
;;
*)
fail "Cannot open: $FILENAME"
;;
esac
;;
answer:pategory:1)
if [ "$ANSWER" = "answer" ]; then
2020-10-16 14:18:44 -06:00
echo '{"Correct":true}'
2020-09-04 15:29:06 -06:00
else
2020-10-16 14:18:44 -06:00
echo '{"Correct":false}'
2020-09-04 15:29:06 -06:00
fi
;;
answer:pategory:2)
fail "Internal error"
;;
*)
2020-09-04 15:29:06 -06:00
fail "ERROR: Unknown action: $action"
;;
esac