From f9f4e27535406efdafdf78c9e7f7b577adb3f88d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 19 Jan 2024 08:28:48 -0800 Subject: [PATCH] Add 1998/schweikh2/try.sh --- 1998/schweikh2/README.md | 5 +++-- 1998/schweikh2/try.sh | 32 ++++++++++++++++++++++++++++++++ thanks-for-help.md | 2 ++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 1998/schweikh2/try.sh diff --git a/1998/schweikh2/README.md b/1998/schweikh2/README.md index 683857911..1f646d895 100644 --- a/1998/schweikh2/README.md +++ b/1998/schweikh2/README.md @@ -21,13 +21,14 @@ or ## Try: ```sh -./yarng 5 +./try.sh ./yarng # watch what it does ``` -What is the difference there? +What is the difference between what is in the script and running `yarng` without +an arg? ## Judges' remarks: diff --git a/1998/schweikh2/try.sh b/1998/schweikh2/try.sh new file mode 100755 index 000000000..0d07488a5 --- /dev/null +++ b/1998/schweikh2/try.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1998/schweikh2 +# + +# 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 + +i=0 +while [[ "$i" -lt 3 ]]; do + NUM="$((RANDOM % 10))" + read -r -n 1 -p "Press any key to run: ./yarng $NUM: " + echo 1>&2 + ./yarng "$NUM" + echo 1>&2 + + read -r -n 1 -p "Press any key to run: ./yarng $NUM: " + echo 1>&2 + ./yarng "$NUM" + echo 1>&2 + + ((i++)) +done diff --git a/thanks-for-help.md b/thanks-for-help.md index abfebc6d1..4003752ed 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2428,6 +2428,8 @@ Cody also added an `int` after `register` in `main()` in case clang decides to have a problem with that in the future which is not entirely out of the question. +Cody also added the [try.sh](/1998/schweikh2/try.sh) script. + ## [1998/schweikh3](/1998/schweikh3/schweikh3.c) ([README.md](/1998/schweikh3/README.md]))