From 1920ca72d889f6ac3d366005b7b3bd0b4f51aefb Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 28 Dec 2023 07:51:28 -0800 Subject: [PATCH] Add 1986/stein/stein.sh This script runs the two commands suggested in order to get it to output cleanly. It is suggested other systems might need another set of characters but one can also get away with just using ./stein so this is also done but at the end of the script to not cause any problems (it doesn't show a newline at output). --- 1986/stein/README.md | 2 +- 1986/stein/stein.sh | 25 +++++++++++++++++++++++++ thanks-for-help.md | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 1986/stein/stein.sh diff --git a/1986/stein/README.md b/1986/stein/README.md index c6c1a5ce4..b3a65a8e0 100644 --- a/1986/stein/README.md +++ b/1986/stein/README.md @@ -19,7 +19,7 @@ into 3 lines. Join all lines into a single line to recreate the original file. -The 015 in the above printf command produces a control-N. +The `\015` in the above `printf(1)` command produces a control-N. One some machines, a control-M control-N arg is needed to get the command to output cleanly: diff --git a/1986/stein/stein.sh b/1986/stein/stein.sh new file mode 100755 index 000000000..ea144dc53 --- /dev/null +++ b/1986/stein/stein.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1986/stein +# + +# 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 + +echo "$ ./stein \$(printf \"\\015\\015\"); echo" 1>&2 +./stein $(printf "\015\015"); echo + +echo "$ ./stein \$(printf \"\\014\\015\"); echo" 1>&2 +./stein $(printf "\014\015"); echo + +echo "$ ./stein" 1>&2 +./stein diff --git a/thanks-for-help.md b/thanks-for-help.md index c5af8919b..cc9789391 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -406,6 +406,9 @@ being longer (in 1986 a one liner could be longer) was split to three lines to avoid problems with news and mail but as it was the 'Best one liner' it is now one line. +Cody also added the [stein.sh](/1986/stein/stein.sh) script which runs the two +commands that we suggest in order to get it to show clean output. + ## [1986/wall](/1986/wall/wall.c) ([README.md](/1986/wall/README.md]))