From c306944d3f69a0e529683e4c110eff35c586981a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:23:32 -0800 Subject: [PATCH] Add try.sh to 2014/endoh2 + formatting/typo checks --- 2014/endoh2/.gitignore | 4 ++++ 2014/endoh2/README.md | 11 +++++---- 2014/endoh2/try.sh | 52 ++++++++++++++++++++++++++++++++++++++++++ thanks-for-fixes.md | 5 ++++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100755 2014/endoh2/try.sh diff --git a/2014/endoh2/.gitignore b/2014/endoh2/.gitignore index a1e7bc695..6846e3735 100644 --- a/2014/endoh2/.gitignore +++ b/2014/endoh2/.gitignore @@ -1,2 +1,6 @@ prog prog.orig +hello.c +hello +ioccc.c +ioccc diff --git a/2014/endoh2/README.md b/2014/endoh2/README.md index b92a86994..02a783f0d 100644 --- a/2014/endoh2/README.md +++ b/2014/endoh2/README.md @@ -32,6 +32,7 @@ in the DNA code of the code? Perhaps there are 23 reasons? :-) ## Author's remarks: + ### Remarks This chromosome program synthesizes a double helix. @@ -39,14 +40,16 @@ The helix can also be compiled as a C program. Enjoy DNA programming! -### For more information / backgroud reading: + +### For more information / background reading: * This program was inspired by Acme::DoubleHelix: - http://search.cpan.org/~xern/Acme-DoubleHelix-0.01/ + * The synthesized helix just includes the original program at the head. - Do you see how `prog.c` determines whether it was invoked as a standalone program or included as a header file? - Note that it does not use any gcc extension such as `__INCLUDE_LEVEL__`. + Do you see how [prog.c](prog.c) determines whether it was invoked as a + standalone program or included as a header file? Note that it does not use any + gcc extension such as `__INCLUDE_LEVEL__`. * The synthesized helix of course follows the base-pairing rules for DNA: A is bonding only to T, and C is bonding only to G. diff --git a/2014/endoh2/try.sh b/2014/endoh2/try.sh new file mode 100755 index 000000000..0fbfd5a61 --- /dev/null +++ b/2014/endoh2/try.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2014/endoh2 +# + +# 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 Hello | ./prog: " +echo 1>&2 +echo Hello | ./prog +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo IOCCC | ./prog: " +echo 1>&2 +echo IOCCC | ./prog +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo Hello | ./prog > hello.c: " +echo 1>&2 +echo Hello | ./prog > hello.c +echo 1>&2 + +read -r -n 1 -p "Press any key to compile hello.c: " +echo 1>&2 +make hello >/dev/null +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./hello: " +./hello +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo IOCCC | ./prog > ioccc.c: " +echo 1>&2 +echo IOCCC | ./prog > ioccc.c +echo 1>&2 + +read -r -n 1 -p "Press any key to compile ioccc.c: " +echo 1>&2 +make ioccc >/dev/null +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./ioccc: " +echo 1>&2 +./ioccc diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index fc2dbae05..cdafd46cd 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3705,6 +3705,11 @@ file to [spoilers.md](2014/endoh1/spoilers.md) to be clearer in its purpose as it is a file with spoilers (and too close to README.md?). +## [2014/endoh2](2014/endoh2/prog.c) ([README.md](2014/endoh2/README.md])) + +[Cody](#cody) added the [try.sh](2014/endoh2/try.sh) script. + + ## [2014/maffiodo1](2014/maffiodo1/prog.c) ([README.md](2014/maffiodo1/README.md])) [Cody](#cody) fixed the build for this entry: it does not require