Improve and modularize 2012/zeitak/try.sh

This commit is contained in:
Cody Boone Ferguson committed 2024-02-17 08:29:43 -08:00
1 parent 12e71e60e4
commit 187d177659
1 file changed
+32 -129
+32 -129
View File
@@ -18,144 +18,47 @@ clear
# assume no error: set ERROR to 0
ERROR=0
read -r -n 1 -p "Press any key to test zeitak.c for nesting errors: "
echo 1>&2
./zeitak < zeitak.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 3 ]]; then
echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak()
{
if [[ "$#" != 2 ]]; then
echo "$0: zeitak() expects two args, got: $#" 1>&2
return
fi
echo "$ cat anonymous.c" 1>&2
cat anonymous.c
echo 1>&2
read -r -n 1 -p "Press any key to test anonymous.c for nesting errors: "
echo 1>&2
./zeitak < anonymous.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 3 ]]; then
echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
read -r -n 1 -p "Press any key to run show $1 (space = next page, q = quit): "
echo 1>&2
less -rEXFK "$1"
read -r -n 1 -p "Press any key to test $1 for nesting errors: "
echo 1>&2
./zeitak < "$1"
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne "$2" ]]; then
echo "Error: did not get exit code $2: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
}
echo "$ cat anonymous.alt.c" 1>&2
cat anonymous.alt.c
echo 1>&2
read -r -n 1 -p "Press any key to test anonymous.alt.c for nesting errors: "
echo 1>&2
./zeitak < anonymous.alt.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 3 ]]; then
echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak zeitak.c 3
echo "$ cat incorrect.brace.c" 1>&2
cat incorrect.brace.c
echo 1>&2
read -r -n 1 -p "Press any key to test incorrect.brace.c: "
echo 1>&2
./zeitak < incorrect.brace.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 10 ]]; then
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak anonymous.c 3
echo "$ cat incorrect.bracket.c" 1>&2
cat incorrect.bracket.c
echo 1>&2
read -r -n 1 -p "Press any key to test incorrect.bracket.c: "
echo 1>&2
./zeitak < incorrect.bracket.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 10 ]]; then
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak anonymous.alt.c 3
echo "$ cat incorrect.paren.c" 1>&2
cat incorrect.paren.c
echo 1>&2
read -r -n 1 -p "Press any key to test incorrect.paren.c: "
echo 1>&2
./zeitak < incorrect.paren.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 10 ]]; then
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak incorrect.brace.c 10
echo "$ cat incorrect.quote-esc.c" 1>&2
cat incorrect.quote-esc.c
echo 1>&2
read -r -n 1 -p "Press any key to test incorrect.quote-esc.c: "
echo 1>&2
./zeitak < incorrect.quote-esc.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 10 ]]; then
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak incorrect.bracket.c 10
echo "$ cat incorrect.3.quotes.c" 1>&2
cat incorrect.3.quotes.c
echo 1>&2
read -r -n 1 -p "Press any key to test incorrect.3.quotes.c: "
echo 1>&2
./zeitak < incorrect.3.quotes.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 10 ]]; then
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak incorrect.paren.c 10
echo "$ cat incorrect.single.quote.c" 1>&2
cat incorrect.single.quote.c
echo 1>&2
read -r -n 1 -p "Press any key to test incorrect.single.quote.c: "
echo 1>&2
./zeitak < incorrect.single.quote.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 10 ]]; then
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak incorrect.quote-esc.c 10
echo "$ cat incorrect.1.quote.c" 1>&2
cat incorrect.1.quote.c
echo 1>&2
read -r -n 1 -p "Press any key to test incorrect.1.quote.c: "
echo 1>&2
./zeitak < incorrect.1.quote.c
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 10 ]]; then
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak incorrect.3.quotes.c 10
echo "$ cat incorrect.txt" 1>&2
cat incorrect.txt
echo 1>&2
read -r -n 1 -p "Press any key to test incorrect.txt: "
echo 1>&2
./zeitak < incorrect.txt
EXIT_CODE="$?"
if [[ "$EXIT_CODE" -ne 10 ]]; then
echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2
ERROR=1
fi
echo 1>&2
zeitak incorrect.single.quote.c 10
zeitak incorrect.1.quote.c 10
zeitak incorrect.txt 10
exit "$ERROR"