From 3065fc20d8bb9d87bc2b9af79661f76fe5ab8b66 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:19:07 -0800 Subject: [PATCH] Add 1990/scjones/try.sh The script allows one to more easily see (and verify) what the entry does. This involves a temporary file that is created (and removed at the end of the script but which has also been added to .gitignore). --- 1990/scjones/.gitignore | 1 + 1990/scjones/README.md | 7 +++++++ 1990/scjones/try.sh | 35 +++++++++++++++++++++++++++++++++++ thanks-for-help.md | 3 +++ 4 files changed, 46 insertions(+) create mode 100755 1990/scjones/try.sh diff --git a/1990/scjones/.gitignore b/1990/scjones/.gitignore index 828493f4e..ded6f9f81 100644 --- a/1990/scjones/.gitignore +++ b/1990/scjones/.gitignore @@ -7,3 +7,4 @@ indent.o prog.orig scjones scjones.orig +scjones.tmp.c diff --git a/1990/scjones/README.md b/1990/scjones/README.md index 6269c342c..f8d4b8f01 100644 --- a/1990/scjones/README.md +++ b/1990/scjones/README.md @@ -12,6 +12,13 @@ make all ``` +## Try: + +```sh +./try.sh +``` + + ## Judges' remarks: The addition of trigraphs has made it easier to make programs hard to read. It diff --git a/1990/scjones/try.sh b/1990/scjones/try.sh new file mode 100755 index 000000000..45ff294dc --- /dev/null +++ b/1990/scjones/try.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1990/scjones +# + +# 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 scjones.c: " +echo 1>&2 +less -rEXF scjones.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./scjones (space = next page, q = quit): " +echo 1>&2 +./scjones | less -rEXF + +read -r -n 1 -p "Press any key to run: ./scjones > scjones.tmp.c: " +echo 1>&2 +./scjones > scjones.tmp.c +echo 1>&2 + +read -r -n 1 -p "Press any key to compare scjones.c and scjones.tmp.c: " +echo 1>&2 +diff -s scjones.c scjones.tmp.c +rm scjones.tmp.c diff --git a/thanks-for-help.md b/thanks-for-help.md index 7ab82bd26..78de83f87 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -1056,6 +1056,9 @@ something else and is recommended by the author as well. [Yusuke](#yusuke) suggested `-ansi` to get the entry to compile due to trigraphs and [Cody](#cody) suggested `-trigraphs`. Both work but we used Yusuke's idea. +Cody added the [try.sh](/1990/scjones/try.sh) script to show exactly what the +entry does. + ## [1990/tbr](/1990/tbr/tbr.c) ([README.md](/1990/tbr/README.md]))