diff --git a/1987/heckbert/README.md b/1987/heckbert/README.md index 70770ba82..7754f1fc6 100644 --- a/1987/heckbert/README.md +++ b/1987/heckbert/README.md @@ -20,15 +20,7 @@ where col is the number of columns to fold at and file is the file to fold. ### Try: ```sh -./heckbert 40 < heckbert.c > ph.c; make ph -./ph 21 < heckbert.c > bar.c; make bar - -``` - -Ask yourself what happens to `foo.md` if you try: - -```sh -./ph 40 < README.md > foo.md +./try.sh ``` diff --git a/1987/heckbert/try.sh b/1987/heckbert/try.sh new file mode 100755 index 000000000..cca1406c1 --- /dev/null +++ b/1987/heckbert/try.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1987/heckbert +# + +# 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 heckbert.c (space = next page, q = quit): " +echo 1>&2 +less -rEXF heckbert.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./heckbert 40 < heckbert.c: " +echo 1>&2 +./heckbert 40 < heckbert.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./heckbert 40 < heckbert.c > ph.c; make ph: " +./heckbert 40 < heckbert.c > ph.c; make ph +echo 1>&2 + +read -r -n 1 -p "Press any key to show ph.c (space = next page, q = quit): " +echo 1>&2 +less -rEXF ph.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./ph 21 < heckbert.c > bar.c; make bar: " +echo 1>&2 +./ph 21 < heckbert.c > bar.c; make bar +echo 1>&2 + +read -r -n 1 -p "Press any key to show bar.c (space = next page, q = quit): " +echo 1>&2 +less -rEXF bar.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./bar 79 < bar.c > foo.c: " +echo 1>&2 +./bar 79 < bar.c > foo.c +echo 1>&2 + +read -r -n 1 -p "Press any key to show difference between foo.c and heckbert.c: " +echo 1>&2 +diff -s heckbert.c foo.c + +read -r -n 1 -p "Press any key to run: ./ph 40 < README.md > foo.md: " +./ph 40 < README.md > foo.md +echo 1>&2 +echo "Now what happened to foo.md?" diff --git a/thanks-for-help.md b/thanks-for-help.md index a4f547dcf..75776d279 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -510,6 +510,9 @@ There might have been other changes as well. [Cody](#cody) made this look more like the original entry by restoring the `#define` of `define`. It's not used but it now looks closer to the original. +Cody also added the [try.sh](1987/heckbert/try.sh) script which shows how the +program works but also how the folded code can recreate the original. + Also because `index(3)` is deprecated and in some systems requires the inclusion of `strings.h` and because it's identical in use to `strchr(3)` (and we noted that for System V we had to do this) Cody added to the Makefile