From 99e79b1e13bd62e27fcc929b232c03b4ccd1775d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:57:28 -0800 Subject: [PATCH] Add 1998/df/try.sh This script runs repeatedly until (when prompted) one hits 'q' (or 'Q') or else sends ctrl-c/intr. I also added a question to the extra credit questions: are there any misspelt words and if there are what are they? I also added that there's a way to cheat very easily but I did not say how to do it. It should be pretty obvious how to do it to anyone who tries the program once or if not once a few times. --- 1998/df/README.md | 14 ++++++++++++++ 1998/df/try.sh | 25 +++++++++++++++++++++++++ thanks-for-help.md | 10 +++++++--- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100755 1998/df/try.sh diff --git a/1998/df/README.md b/1998/df/README.md index db17ebda2..2d51dd7e2 100644 --- a/1998/df/README.md +++ b/1998/df/README.md @@ -11,6 +11,19 @@ make all ./df ``` + +## Try: + +```sh +./try.sh +``` + +This will run the program in a loop until you exit (`q` when prompted or +ctrl-c/intr). + +Can you figure out a very simple pipeline to cheat? + + ## Judges' remarks; Everyone talks about how data hiding can produce clearer code; I am @@ -33,6 +46,7 @@ Extra credit questions: - Where are the words stored? - How many words does this entry use? - Can you add more words to the program and still make it work? +- Are there any misspelt words? If yes what are they? ## Author's remarks: diff --git a/1998/df/try.sh b/1998/df/try.sh new file mode 100755 index 000000000..284ebd4be --- /dev/null +++ b/1998/df/try.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1998/df +# + +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +make CC="$CC" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +while [[ 1 ]]; do + read -r -n 1 -p "Press any key to run ./df or 'q' to quit: " + echo 1>&2 + if [[ "$REPLY" = "q" || "$REPLY" = "Q" ]]; then + exit 0 + fi + ./df +done diff --git a/thanks-for-help.md b/thanks-for-help.md index 8c78fd3c9..abfebc6d1 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2269,10 +2269,14 @@ prior to each run. [Cody](#cody) changed a `int *` used for `fopen(3)` to be a `FILE *` to be more correct and prevent any possible problems in some systems (which has happened). -Cody also made the fixed version look more like the original version by using +Cody also made the fixed version to look more like the original version by using the old style of `main()` args so that it reads `i,love_unix` more naturally, -and by changing the typedef `lint` (to `int` - see the code for why this has to -be done in modern systems) to be `_int`. +and by changing the `typedef int lint` to be `typedef int _int`. See the code +for why this has to be done this way. + +Cody also added the [try.sh](/1998/df/try.sh) script which runs the program in a +loop until one hits `q` (or `Q`) or sends intr/ctrl-c. He also proposed there's +a way to cheat very easily. Can you figure out how? ## [1998/dlowe](/1998/dlowe/dlowe.c) ([README.md](/1998/dlowe/README.md]))