Add try scripts to 1993/plummer

The two scripts allow one to specify the number and the arg
(corresponding to the argv[1] and argv[2] of the program). The alt
script has a way to redefine the SLEEP variable (in the Makefile) like

    SLEEP=500 ./try.alt.sh
This commit is contained in:
Cody Boone Ferguson committed 2024-01-15 04:26:29 -08:00
1 parent 3c642f74f4
commit 90423742bd
5 files changed
+151 -26

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
#
# try.alt.sh - demonstrate IOCCC winner 1993/plummer alt code
#
# 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
# let user change the sleep duration if they wish
#
if [[ -z "$SLEEP" ]]; then
SLEEP=1000
fi
# let user change the number if they wish to
#
if [[ "$#" -lt 1 || -z "$1" ]]; then
NUMBER="01234567890876543210"
else
NUMBER="$1"
fi
# let user change the arg if they wish to
#
if [[ "$#" -lt 2 || -z "$2" ]]; then
ARG="xxx"
else
ARG="$2"
fi
make clobber CC="$CC" SLEEP="$SLEEP" alt >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "$ ./plummer.alt $NUMBER $ARG" 1>&2
read -r -n 1 -p "Press any key to continue (send intr/ctrl-c to terminate): "
echo 1>&2
./plummer.alt "$NUMBER" "$ARG"