From 01d50b7ff47959a1e3cda9053fc528068f1afd35 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:28:07 -0800 Subject: [PATCH] Add 1996/dalbec/try.sh --- 1996/dalbec/README.md | 2 +- 1996/dalbec/try.sh | 26 ++++++++++++++++++++++++++ thanks-for-help.md | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 1996/dalbec/try.sh diff --git a/1996/dalbec/README.md b/1996/dalbec/README.md index d98715e93..189019e30 100644 --- a/1996/dalbec/README.md +++ b/1996/dalbec/README.md @@ -15,7 +15,7 @@ make all ## Try: ```sh -./dalbec 3 | head -n 29 +./try.sh ``` Why does the output end with 121? diff --git a/1996/dalbec/try.sh b/1996/dalbec/try.sh new file mode 100755 index 000000000..9794cd337 --- /dev/null +++ b/1996/dalbec/try.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# +# try.sh - show IOCCC winner 1996/dalbec +# + +# 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 + +read -r -n 1 -p "Press any key to run: ./dalbec 5 | head -n 29 (space = next page, q = quit): " +echo 1>&2 +./dalbec 5 | head -n 29 | less -rEXF +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./dalbec 3 | head -n 29 (space = next page, q = quit): " +echo 1>&2 +./dalbec 3 | head -n 29 | less -rEXF +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index 93295c5f4..0e3c4dea3 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2123,6 +2123,8 @@ number is printed on a line by itself rather than having a long string of numbers on the same line. This was not put in an alternate version but perhaps it should be. +Cody also added the [try.sh](/1996/dalbec/try.sh) script. + ## [1996/eldby](/1996/eldby/eldby.c) ([README.md](/1996/eldby/README.md]))