From e88b19a307ae5267200f194783e6fbcca9515991 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 19 Jan 2024 05:38:26 -0800 Subject: [PATCH] Add 1996/schweikh1/try.sh --- 1996/schweikh1/README.md | 5 +++-- 1996/schweikh1/try.sh | 27 +++++++++++++++++++++++++++ thanks-for-help.md | 5 +++-- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100755 1996/schweikh1/try.sh diff --git a/1996/schweikh1/README.md b/1996/schweikh1/README.md index dc50fcfa3..9c9488986 100644 --- a/1996/schweikh1/README.md +++ b/1996/schweikh1/README.md @@ -14,10 +14,11 @@ make all ## Try: -To find the day that Easter falls on in the current year: +To find the day that Easter falls on in the current year and to show all Easter +dates from 1582 to 2199: ```sh -./schweikh1 |grep $(date +%Y) +./try.sh ``` diff --git a/1996/schweikh1/try.sh b/1996/schweikh1/try.sh new file mode 100755 index 000000000..591250564 --- /dev/null +++ b/1996/schweikh1/try.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# try.sh - show IOCCC winner 1996/schweikh1 +# + +# 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 show date of Easter this year (./schweikh1 |grep \$(date +%Y)): " +echo 1>&2 +./schweikh1 |grep "$(date +%Y)" +echo 1>&2 + +read -r -n 1 -p "Press any key to show Easter dates from 1582 to 2199 (space = next page, q = quit): " +echo 1>&2 +./schweikh1 | less -rEXF +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index fd125bb5a..522020397 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2173,16 +2173,17 @@ NOTE: if there is no X server running this program will still crash. ## [1996/schweikh1](/1996/schweikh1/schweikh1.c) ([README.md](/1996/schweikh1/README.md])) +[Cody](#cody) added the [try.sh](/1996/schweikh1/try.sh) script. + The author stated that `-I/usr/include` is needed by gcc in Solaris because `errno.h` has two identical extern declarations of `errno`. That leads to an error due to the redefinition of `main` but the `-I` option makes sure the working `/usr/include/rrno.h` is found first, which shouldn't cause any problems on other systems (the other file is -`gcc-lib/sparc-sun-solaris2.5/2.7.2/include/errno.h`). Thus Cody added this to +`gcc-lib/sparc-sun-solaris2.5/2.7.2/include/errno.h`). Thus Cody also added this to the Makefile despite the fact that very few probably use Solaris nowadays. - ## [1996/schweikh2](/1996/schweikh2/schweikh2.c) ([README.md](/1996/schweikh2/README.md])) [Cody](#cody) added the [try.sh](/1996/schweikh2/try.sh) script with a few commands to try