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.
This commit is contained in:
Cody Boone Ferguson committed 2023-12-19 06:13:49 -08:00
1 parent 9c4ca9603b
commit 4e886308f5
4 files changed
+42 -6

No files matched your search

+1 -1
View File
@@ -68,7 +68,7 @@ CINCLUDE=
# Optimization
#
OPT=
OPT= -O3
# Default flags for ANSI C compilation
#
+1 -5
View File
@@ -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
```
+34
View File
@@ -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
+6
View File
@@ -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.