From cf4b113f56c8ef3e1266c77896d65d3de654b3ca Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 30 Jan 2024 08:59:36 -0800 Subject: [PATCH] Improve 2018/hou/try.sh + update bugs.md --- 2018/hou/README.md | 8 ++++++-- 2018/hou/try.sh | 27 ++++++++++++++------------- bugs.md | 9 +++++++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/2018/hou/README.md b/2018/hou/README.md index 10dbab405..553c86d38 100644 --- a/2018/hou/README.md +++ b/2018/hou/README.md @@ -31,9 +31,13 @@ View `output.html` in a browser. ./try.sh ``` -As the script says, open `output.html` in a browser. +The script will generate a JSON file called `ioccc.json`, showing it via +`tee(1)` and then run the program on that. Can you find any problem with the +JSON file? What happens if you try and fix it? -What's not right with the output? How can one fix it? +As the script says, open `ioccc.html` in a browser. + +Is anything wrong with the output? How can you fix it if so? ## Judges' remarks: diff --git a/2018/hou/try.sh b/2018/hou/try.sh index da3625d5c..83698ec7a 100755 --- a/2018/hou/try.sh +++ b/2018/hou/try.sh @@ -17,25 +17,26 @@ clear read -r -n 1 -p "Press any key to run: grep -e '[-?+*/^&|.<>=]' prog.c (space = next page, q = quit): " echo 1>&2 -grep -e '[-?+*/^&|.<>=]' prog.c | less -EXF +grep -e '[-?+*/^&|.<>=]' prog.c | less -rEXFK echo 1>&2 -# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? -# ^-- SC1083 (warning): This { is literal. Check expression (missing ;/\n?) or quote it. -# ^-- SC1083 (warning): This } is literal. Check expression (missing ;/\n?) or quote it. -# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? -# shellcheck disable=SC2140 -# shellcheck disable=SC1083 -echo "(cd ..; ls -lS -- */prog.c) | \ -awk 'BEGIN { print "["; } { print "{\"winner\":\"",\$9,"\", \"size\":",\$5,"},"} END { print "]"}' \ -> ioccc.json" +# remove temp files +rm -f ioccc.html ioccc.json + +echo "$ (cd ..; ls -lS -- */prog.c) | \ +awk 'BEGIN { print \"[\"; } { print \"{\"winner\":\"\",\$9,\"\", \"size\":\",\$5,\"},\"} END { print \"]\"}' \ +| tee ioccc.json" +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 (cd ..; ls -lS -- */prog.c) | \ awk 'BEGIN { print "["; } { print "{\"winner\":\"",$9,"\", \"size\":",$5,"},"} END { print "]"}' \ -> ioccc.json +| tee ioccc.json + +echo "NOTE: for the next step you should get an assertion failure" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog < ioccc.json > ioccc.html: " +echo 1>&2 ./prog < ioccc.json > ioccc.html echo 1>&2 echo "Now open ioccc.html in your browser." 1>&2 - -exit 0 diff --git a/bugs.md b/bugs.md index 6969b7912..4d2587b67 100644 --- a/bugs.md +++ b/bugs.md @@ -3353,7 +3353,7 @@ loop printing whitespace. ### Source code: [2018/hou/prog.c](2018/hou/prog.c) ### Information: [2018/hou/README.md](2018/hou/README.md) -When you run it you will see something like: +When you run it on a JSON file you will see something like: ```sh $ ./prog < ioccc.json > ioccc.html @@ -3361,7 +3361,12 @@ Assertion failed: (rulez), function C, file prog.c, line 124. Abort trap: 6 ``` -but this is expected and the file `ioccc.html` will be generated properly. +(from say running `./try.sh) but this is expected and the file `ioccc.html` will +be generated properly. + +Some JSON files might cause the program to continue to run and seemingly +infinitely increase the size of the output file. This can happen if you try +fixing the syntax error in the generated `ioccc.json` file. ## 2018 mills