Improvements to build and script of 2013/endoh4

The Makefile was modified in such a way that allows one to easily
redefine the size (in the code the S macro). For instance:

    make clobber SIZE=50,50 all

The try.sh was renamed to endoh4.sh as it's more of a wrapper to the
program rather than things to try. Also it now lets one specify more
than one file to feed to the program (in sequence).

The bugs.md was updated - added INABIAF. If the file format is invalid
it will very likely crash.
This commit is contained in:
Cody Boone Ferguson committed 2024-01-27 10:52:18 -08:00
1 parent 6f20a57493
commit d8fa53cc29
5 files changed
+86 -18

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2013/endoh4
#
# 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.
[[ -z "$CC" ]] && CC="cc"
# let user redefine size. This requires that we clobber so that they can change
# it each time.
[[ -z "$SIZE" ]] && SIZE=70,23
make clobber CC="$CC" SIZE="$SIZE" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
# set it so that when program is terminated through various signals we re-enable
# the cursor
trap "tput cnorm;echo" 0 1 2 3 15
# temporarily disable cursor
tput civis
# run program attempting to feed it a file, if specified
if [[ "$#" -gt 0 ]]; then
while [[ "$#" -gt 0 ]]; do
read -r -n 1 -p "Press any key to run: ./endoh4 < $1: "
echo 1>&2
./endoh4 < "$1"
echo 1>&2
shift 1
done
else
# otherwise feed the source code of the program to the program
read -r -n 1 -p "Press any key to run: ./endoh4 < endoh4.c: "
echo 1>&2
./endoh4 < endoh4.c
echo 1>&2
fi
# explicitly set cursor back just in case it's not terminated through one of the
# above signals
tput cnorm