From 4e886308f507d50f32e31b8ba827aafc885ff884 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 19 Dec 2023 06:13:49 -0800 Subject: [PATCH] Add 1989/ovdluhe/try.sh and fix Makefile The try.sh script runs the program on the source file, the README.md and the Makefile in a loop that runs four times. It has one loop so that there is a better chance that it won't show the same output on the same file more than once though it's certainly possible that it will. The optimiser had been left disabled by accident and this has been restored. --- 1989/ovdluhe/Makefile | 2 +- 1989/ovdluhe/README.md | 6 +----- 1989/ovdluhe/try.sh | 34 ++++++++++++++++++++++++++++++++++ thanks-for-help.md | 6 ++++++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100755 1989/ovdluhe/try.sh diff --git a/1989/ovdluhe/Makefile b/1989/ovdluhe/Makefile index eedacb161..fd8cfb68d 100644 --- a/1989/ovdluhe/Makefile +++ b/1989/ovdluhe/Makefile @@ -68,7 +68,7 @@ CINCLUDE= # Optimization # -OPT= +OPT= -O3 # Default flags for ANSI C compilation # diff --git a/1989/ovdluhe/README.md b/1989/ovdluhe/README.md index ff12f3525..6904d0179 100644 --- a/1989/ovdluhe/README.md +++ b/1989/ovdluhe/README.md @@ -22,11 +22,7 @@ by chance or is killed. ### Try: ```sh -./ovdluhe < ./ovdluhe.c -./ovdluhe < ./ovdluhe.c - -./ovdluhe < README.md -./ovdluhe < README.md +./try.sh ; sleep 2 ; ./try.sh ``` diff --git a/1989/ovdluhe/try.sh b/1989/ovdluhe/try.sh new file mode 100755 index 000000000..2b6362d9c --- /dev/null +++ b/1989/ovdluhe/try.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1989/ovdluhe +# + +# 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 +for ((i=0; i<4; ++i)); do + read -r -n 1 -p "Press any key to run: ./ovdluhe < ovdluhe.c: " + echo 1>&2 + ./ovdluhe < ovdluhe.c + echo 1>&2 + + read -r -n 1 -p "Press any key to run: ./ovdluhe < README.md: " + echo 1>&2 + ./ovdluhe < README.md + echo 1>&2 + + read -r -n 1 -p "Press any key to run: ./ovdluhe < Makefile: " + echo 1>&2 + ./ovdluhe < Makefile + echo 1>&2 +done diff --git a/thanks-for-help.md b/thanks-for-help.md index a111c8f0b..5c9298d79 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -744,6 +744,12 @@ and over again, flooding the screen. The problem is that there was a `for` loop that by necessity had to not have an increment stage but only in the `if` path (in the loop itself) did the pointer get updated. +Cody also provided the [try.sh](/1989/ovdluhe/try.sh) script which runs the +program four times on three files to show the different output. It doesn't run +the program on each file four times in a row but rather does it on each file +and starts over, doing it four times, to help with hopefully allowing different +output. + Cody also provided an [alternate version](/1989/ovdluhe/ovdluhe.alt.c) based on the author's remarks. See the README.md for details. The fix described above was fixed in this version too, after it was discovered and fixed.