From d4783f02e7d1e96b3c41afab2bf75f6e1b4d0c28 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 27 Jan 2024 11:16:09 -0800 Subject: [PATCH] Add 2013/morgan1/try.sh --- 2013/morgan1/README.md | 13 +++++-------- 2013/morgan1/try.sh | 36 ++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 2 ++ 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100755 2013/morgan1/try.sh diff --git a/2013/morgan1/README.md b/2013/morgan1/README.md index 10c106721..1b0e00aee 100644 --- a/2013/morgan1/README.md +++ b/2013/morgan1/README.md @@ -8,20 +8,17 @@ make ## To use: ```sh -echo "2013/10/03" | ./morgan1 +echo "YYYY/MM/DD" | ./morgan1 ``` +where `YYYY` is the four digit year, `MM` is the two digit month and `DD` is two +digit day of the month. + ## Try: ```sh -echo "1985/10/28" | ./morgan1 - -echo "1996/12/31" | ./morgan1 - -echo "1986/03/31" | ./morgan1 # Comet Halley (look for 'Ha') - -echo "1997/04/01" | ./morgan1 # Comet Hale-Bopp (look for 'Hb') +./try.sh ``` Try pressing the arrow keys when your focus is in the window. diff --git a/2013/morgan1/try.sh b/2013/morgan1/try.sh new file mode 100755 index 000000000..d90c1cba5 --- /dev/null +++ b/2013/morgan1/try.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2013/morgan1 +# + +# 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: echo 1985/10/28 | ./morgan1: " +echo 1>&2 +echo "1985/10/28" | ./morgan1 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 1996/12/31 | ./morgan1: " +echo 1>&2 +echo "1996/12/31" | ./morgan1 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 1986/03/31 | ./morgan1 # Comet Halley (look for 'Ha'): " +echo 1>&2 +echo "1986/03/31" | ./morgan1 # Comet Halley (look for 'Ha') +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 1997/04/01 | ./morgan1 # Comet Hale-Bopp (look for 'Hb'): " +echo 1>&2 +echo "1997/04/01" | ./morgan1 # Comet Hale-Bopp (look for 'Hb') +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index 29c1f390d..4c3c86c59 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4052,6 +4052,8 @@ Firefox both had the problem. [Cody](#cody) added explicit linking of libm (`-lm`) as not all systems do this implicitly (Linux doesn't seem to but macOS does). +Cody also added the [try.sh](/2013/morgan1/try.sh) script. + ## [2013/robison](/2013/robison/robison.c) ([README.md](/2013/robison/README.md))