From 6a82b0423059700ce677ce60d7808ac26038ac63 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 5 Jan 2024 09:33:34 -0800 Subject: [PATCH] Add 1984/laman/try.sh --- 1984/laman/README.md | 2 ++ 1984/laman/try.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 5 ++-- 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100755 1984/laman/try.sh diff --git a/1984/laman/README.md b/1984/laman/README.md index 91754f326..bfba84d3f 100644 --- a/1984/laman/README.md +++ b/1984/laman/README.md @@ -18,6 +18,8 @@ The program accepts ONE POSITIVE number. Seeing is believing, so try things like: ```sh +./try.sh + ./laman 4 ./laman 9 ./laman 16 diff --git a/1984/laman/try.sh b/1984/laman/try.sh new file mode 100755 index 000000000..99bd095d3 --- /dev/null +++ b/1984/laman/try.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1984/laman +# + +# 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 + +run() +{ + if [[ "$#" -ne 1 ]]; then + echo "$0: expected 1 arg, got: $#" 1>&2 + return + fi + + read -r -n 1 -p "Press any key to run: ./laman $1: " + echo 1>&2 + ./laman "$1" + echo 1>&2 +} + + +run_twice() +{ + if [[ "$#" -ne 1 ]]; then + echo "$0: expected 1 arg, got: $#" 1>&2 + return + fi + + read -r -n 1 -p "Press any key to run: ./laman $1; ./laman $1: " + echo 1>&2 + ./laman "$1"; ./laman "$1" + echo 1>&2 +} +run 4 +run 9 +run 16 + +run_twice 4 +run_twice 9 +run_twice 16 + +read -r -n 1 -p "Press any key to run: ./laman 4; ./laman 9; ./laman 16: " +echo 1>&2 +./laman 4; ./laman 9; ./laman 16 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./laman 4; ./laman 8; ./laman 16; ./laman 32; ./laman 64: " +echo 1>&2 +./laman 4; ./laman 8; ./laman 16; ./laman 32; ./laman 64 +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index 145ded0c4..79d74dea6 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -121,9 +121,10 @@ cd 1984/decot ; make diff_orig_prog ## [1984/laman](/1984/laman/laman.c) ([README.md](/1984/laman/README.md])) -[Cody](#cody) fixed this to not crash when no arg is specified. Note that if the arg is -not a positive number it will not do anything useful or anything at all. +[Cody](#cody) added the [try.sh](1984/laman/try.sh) script. +Cody also fixed this to not crash when no arg is specified. Note that if the arg +is not a positive number it will not do anything useful or anything at all. This was fixed on 30 October 2023 after the bug status was changed from INABIAF (it's not a bug it's a feature) to bug.