From 7c12aeeb0d540230e8fc98f592e7fce27e37042c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 05:48:40 -0800 Subject: [PATCH 01/12] Reword use / alt use in 1989/jar.1 + typo fixes --- 1989/jar.1/README.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/1989/jar.1/README.md b/1989/jar.1/README.md index a95b1b358..c3cdc71b0 100644 --- a/1989/jar.1/README.md +++ b/1989/jar.1/README.md @@ -7,21 +7,19 @@ make clobber all ``` There is an alternate version with a slight difference that you may wish to try. -See [Alternate code](#alternate-code) below. +See the [Alternate code](#alternate-code) section below for more details. ## To use: -NOTE: this will run the program itself: - ```sh -make clobber all +./jar.1 ``` ## Alternate code: -This code, which prints something slightly different, is provided as well. +This alternate code, which prints something slightly different, is provided as well. ### Alternate build: @@ -35,11 +33,9 @@ make clobber alt ### Alternate use: -Alternatively, you can run it directly: - ```sh -./jar.1.alt.sh +./jar.1.alt ``` @@ -53,7 +49,7 @@ cc -c -o /dev/tty jar.1.c ``` As a last resort the `jar.1.sh` script provided simulates -writing the raw binary the .o file to the terminal. +writing the raw binary of the .o file to the terminal. Abuse of the rules winners usually result in a change of the rules. Starting in 1990, compiling entries must result an regular file @@ -78,10 +74,10 @@ strings utility before writing to standard output instead of `/dev/tty`. As a historical note, the Makefile does echo the original command -to standard output, the original shell command that did write raw +to standard output, the original shell command that once wrote raw binary to the `/dev/tty` special file. -The use piping raw binary thru stings makes the original 1989 output +The use of piping raw binary thru stings makes the original 1989 output more apparent, as was the case when using dumb CRT terminals (some do dumb that they couldn't even process simple ANSI escape sequences) were more common. From 66308ecd7c79e12c1a0d0fc447474309884b6897 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 08:19:11 -0800 Subject: [PATCH 02/12] Improve 1989/jar.2/try.sh Now it will cat each file before running jar.2 on it, prompting for both cat and the command itself. Spaces are added in between commands to help let things stand out better. --- 1989/jar.2/README.md | 2 -- 1989/jar.2/try.sh | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/1989/jar.2/README.md b/1989/jar.2/README.md index f562a1e9e..7310f9c8e 100644 --- a/1989/jar.2/README.md +++ b/1989/jar.2/README.md @@ -22,8 +22,6 @@ NOTE: this entry will likely segfault on invalid input. ```sh ./try.sh -cat chocolate_cake.lisp ; ./jar.2 < chocolate_cake.lisp - ./try.sh chocolate_cake.lisp ./try.sh try.txt diff --git a/1989/jar.2/try.sh b/1989/jar.2/try.sh index ae89cb042..9b66f5242 100755 --- a/1989/jar.2/try.sh +++ b/1989/jar.2/try.sh @@ -19,8 +19,13 @@ fi for f in $FILES; do if [[ -e "$f" && -r "$f" ]]; then + read -r -n 1 -p "Press any key to run: cat $f: " + echo 1>&2 + cat "$f" + echo 1>&2 read -r -n 1 -p "Press any key to run: ./jar.2 < $f: " echo 1>&2 ./jar.2 < "$f" + echo 1>&2 fi done From 4238aac1ace40c076cb0085562975070a71ca73c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 08:25:07 -0800 Subject: [PATCH 03/12] Clarify valid range of P in 1989/ovdluhe alt code --- 1989/ovdluhe/README.md | 10 ++++++---- thanks-for-help.md | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/1989/ovdluhe/README.md b/1989/ovdluhe/README.md index 84fb6c747..22b029c5c 100644 --- a/1989/ovdluhe/README.md +++ b/1989/ovdluhe/README.md @@ -15,7 +15,7 @@ Run the program this way: ./ovdluhe < textfile ``` -The program stops when it reaches the end of the template buffer\ +The program stops when it reaches the end of the template buffer by chance or is killed. @@ -39,8 +39,9 @@ make P=9 clobber alt ``` You do not have to define `P` but if you do you can replace the value with -whatever you wish, as long as it's an int (or evaluates to an int like the -default `(A< Date: Fri, 12 Jan 2024 08:36:04 -0800 Subject: [PATCH 04/12] Add 1989/robison/try.sh Also updated bugs.md with another case where the program might 'break into tiny bits' but as a feature not a bug. Checking the source code will give all you need to know about the 'problem' quite well. --- 1989/robison/README.md | 22 ++++++---------------- 1989/robison/try.sh | 41 +++++++++++++++++++++++++++++++++++++++++ bugs.md | 3 +++ thanks-for-help.md | 2 ++ 4 files changed, 52 insertions(+), 16 deletions(-) create mode 100755 1989/robison/try.sh diff --git a/1989/robison/README.md b/1989/robison/README.md index d39e3f49f..a1746bf11 100644 --- a/1989/robison/README.md +++ b/1989/robison/README.md @@ -29,27 +29,17 @@ For more detailed information see [1989 robison in bugs.md](/bugs.md#1989-robiso ```sh ./robison 11x10 +# enter other expressions -echo 1x10x111 | ./robison - -echo 1+1+10 | ./robison - -echo 100 - 1 | ./robison - -echo -100 x 100 + 1 | ./robison +./try.sh echo 100 / 100 | ./robison # <-- what happens here ? ``` -NOTE: This program will very likely crash or break into tiny bits -:-) if you feed it numbers with non-binary digits. - -This is supposed to happen. As is written in the -[The Jargon File](http://catb.org/jargon/html/F/feature.html): - -``` -That's not a bug, that's a feature. -``` +NOTE: This program will very likely crash or break into tiny bits :-) if you +feed it numbers with non-binary digits. This, as you might notice if you try one +of the above commands, can happen with other input as well. If you wish to +understand why this happens check the source code. ## Judges' remarks: diff --git a/1989/robison/try.sh b/1989/robison/try.sh new file mode 100755 index 000000000..a31227d8c --- /dev/null +++ b/1989/robison/try.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1989/robison +# + +# 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 1x10x111 | ./robison: " +echo 1>&2 +echo 1x10x111 | ./robison +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 1+1+10 | ./robison: " +echo 1>&2 +echo 1+1+10 | ./robison +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 100 - 1 | ./robison: " +echo 1>&2 +echo 100 - 1 | ./robison +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo -100 x 100 + 1 | ./robison: " +echo 1>&2 +echo -100 x 100 + 1 | ./robison +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 101x111-100 | ./robison: " +echo 1>&2 +echo 101x111-100 | ./robison +echo 1>&2 diff --git a/bugs.md b/bugs.md index d2f3f6b49..55deb8dac 100644 --- a/bugs.md +++ b/bugs.md @@ -543,6 +543,9 @@ If you want to try and fix this (mis)feature, you are welcome to try. This program will very likely crash or break into tiny bits :-) if you feed it numbers with non-binary digits. +There are also other cases where this can happen for instance using unsupported +operators like `/`. To see what operators are supported check the source code. + ## 1989 westley diff --git a/thanks-for-help.md b/thanks-for-help.md index b07ee72f0..685b0742f 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -849,6 +849,8 @@ cd 1989/robison ; make diff_orig_prog (It adds the C token pasting operator `##` instead of `/**/`.) +Cody also added the [try.sh](/1989/robison/try.sh) script. + ## [1989/tromp](/1989/tromp/tromp.c) ([README.md](/1989/tromp/README.md])) From d5da633a4a846f3265fbccbadcc82c42bfe30c6b Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 08:42:45 -0800 Subject: [PATCH 05/12] Remove trailing newlines in 1989/vanb/try.sh --- 1989/vanb/try.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/1989/vanb/try.sh b/1989/vanb/try.sh index 38b74d35b..0487f0039 100755 --- a/1989/vanb/try.sh +++ b/1989/vanb/try.sh @@ -23,6 +23,3 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./vanb unix is better than os/2 (space = next page, q = quit): " echo 1>&2 ./vanb unix is better than os/2 | less -rEXF - - - From 04cf7822ae2e1e0c1c5ca2f1e6f30b58fb73d624 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 08:58:12 -0800 Subject: [PATCH 06/12] Add 1990/baruch/try.sh --- 1990/baruch/README.md | 3 ++- 1990/baruch/try.sh | 27 +++++++++++++++++++++++++++ thanks-for-help.md | 6 ++++-- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100755 1990/baruch/try.sh diff --git a/1990/baruch/README.md b/1990/baruch/README.md index 6aa1a8e43..825dcb4d1 100644 --- a/1990/baruch/README.md +++ b/1990/baruch/README.md @@ -4,7 +4,8 @@ make all ``` -There is [alternate code](#alternate-code) for those using Turbo-C or MSC. +There is an alternate version for those using Turbo-C or MSC. See [alternate +code](#alternate-code) below for details. ## To use: diff --git a/1990/baruch/try.sh b/1990/baruch/try.sh new file mode 100755 index 000000000..28822ca1a --- /dev/null +++ b/1990/baruch/try.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1990/baruch +# + +# 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 5 | ./baruch (space = next page, q = quit): " +echo 1>&2 +echo 5 | ./baruch | less -rEXF +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 2 | ./baruch: " +echo 1>&2 +echo 2 | ./baruch +echo "Why was there no output? What other conditions cause this?" 1>&2 +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index 685b0742f..a2594a875 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -961,11 +961,13 @@ environmental variable; see the README.md for details. ## [1990/baruch](/1990/baruch/baruch.c) ([README.md](/1990/baruch/README.md])) -[Cody](#cody) added an [alternate version](/1990/baruch/baruch.alt.c) which allows Turbo-C +[Cody](#cody) added the [try.sh](/1990/baruch/try.sh) script. + +Cody also added an [alternate version](/1990/baruch/baruch.alt.c) which allows Turbo-C and MSC to compile this code, based on the authors' remarks, except that Cody did not change the `" #Q"` string as that showed worse looking output instead of improved output though he has no way to test the compilers in -question. YMMV. +question (i.e. it was only tested in the original entry). YMMV. Although this is appreciated we agree with him that no one [very few](https://en.wikipedia.org/wiki/0) From 60ca3e63e2a2a038ddff456c1685ff553b01ef1e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:08:31 -0800 Subject: [PATCH 07/12] Add 1990/dg/try.sh It runs the program with a couple strings and then it feeds the source code to the program (piped to less) as well (after showing the source code with less). --- 1990/dg/README.md | 2 +- 1990/dg/try.sh | 38 ++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 2 ++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 1990/dg/try.sh diff --git a/1990/dg/README.md b/1990/dg/README.md index bce849565..d86ea91c5 100644 --- a/1990/dg/README.md +++ b/1990/dg/README.md @@ -15,7 +15,7 @@ echo foo bar | ./dg ### Try: ```sh -echo "to C or not to C" | ./dg +./try.sh ``` diff --git a/1990/dg/try.sh b/1990/dg/try.sh new file mode 100755 index 000000000..001793747 --- /dev/null +++ b/1990/dg/try.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1990/dg +# + +# 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 'to C or not to C' | ./dg: " +echo 1>&2 +echo 'to C or not to C' | ./dg +echo 1>&2 + +echo "$ echo 'The quick brown fox jumps over the lazy dog' | ./dg" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +echo 'The quick brown fox jumps over the lazy dog' | ./dg +echo 1>&2 + +read -r -n 1 -p "Press any key to show dg.c (space = next page, q = quit): " +echo 1>&2 +less -rEXF dg.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./dg < dg.c (space = next page, q = quit): " +echo 1>&2 +./dg < dg.c | less -rEXF +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index a2594a875..7ab82bd26 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -1024,6 +1024,8 @@ but later Cody added it back to make it more like the original). The second problem was suggested by the judges at the time of judging, to do with if the C preprocessor botches single quotes in cpp expansion. +Cody also added the [try.sh](/1990/dg/try.sh) script. + ## [1990/jaw](/1990/jaw/jaw.c) ([README.md](/1990/jaw/README.md])) From 9a69a9dd241c92b2ce53b96caa38236287786b14 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:12:44 -0800 Subject: [PATCH 08/12] Improve 1990/jaw/try.sh --- 1990/jaw/try.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/1990/jaw/try.sh b/1990/jaw/try.sh index 1398ce7aa..dc79680b1 100755 --- a/1990/jaw/try.sh +++ b/1990/jaw/try.sh @@ -1,6 +1,24 @@ #!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1990/jaw +# -echo "Running shark.sh:" +# 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 "$ ./shark.sh atob shark.sh README.md jaw.c try.sh > receive" +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 ./shark.sh atob shark.sh README.md jaw.c try.sh > receive || exit 1 echo "Done." @@ -15,11 +33,13 @@ mkdir -p test || exit 0 cd test || exit chmod +x ../receive # run the script -echo "Attempting to extract files:" -../receive - +read -r -n 1 -p "Press any key to run ../receive (extract files): " +echo 1>&2 +../receive +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ls -al: " echo 1>&2 -echo "$ ls -al" 1>&2 ls -al echo 1>&2 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 09/12] 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])) From fd57e523bfc869f42e85c87080836ead66d7a28b Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:24:50 -0800 Subject: [PATCH 10/12] Add 1990/tbr to bugs.md (INABIAF) --- 1990/tbr/README.md | 25 +++++++++++++++---------- bugs.md | 10 ++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/1990/tbr/README.md b/1990/tbr/README.md index d355c95cc..3c6b3e2e9 100644 --- a/1990/tbr/README.md +++ b/1990/tbr/README.md @@ -4,7 +4,19 @@ make all ``` -There is an [alternate version](#alternate-code) to this program. +The authors provided another version of this program. See the [alternate +version](#alternate-code) section below. + + +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: INABIAF - please **DO NOT** fix +``` + +For more detailed information see [1990 tbr in bugs.md](/bugs.md#1990-tbr). ### A note about the fixes of this entry in 2023: @@ -21,7 +33,7 @@ $ warning: this program uses gets(), which is unsafe. which kind of hid the prompt. Thus the entry was changed to use `fgets(3)` which is referred to later in this file. -Also `exit(3)` returns void but the entry was using it in a binary expression so +Also `exit(3)` returns `void` but the entry was using it in a binary expression so this entry would not compile in modern systems. This fix is also referred to below, in the [alternate version](#alternate-code) section. @@ -58,13 +70,6 @@ vi tbr.c What happens if you try using `cd -` to return to previous directory? What about `cd` with no args? -This is supposed to happen. As is written in the -[The Jargon File](http://catb.org/jargon/html/F/feature.html): - -``` -That's not a bug, that's a feature. -``` - The authors include a section called [BUGS](#bugs) that, because they were documented, are not considered bugs as such in the context of the contest. @@ -87,7 +92,7 @@ r(o,0)D o)D*f):4,wait(0):(o?dup2(*f,0)D*f)D o):*i?1 D e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||(exit(1),0):5;} ``` -and in the [alternate source](tbr.alt.c). It has the `exit()` returns void fix +and in the [alternate source](tbr.alt.c). It has the `exit()` returns `void` fix as well as the `gets()` to `fgets()` fix applied to it to make it functionally equivalent like the authors intended. diff --git a/bugs.md b/bugs.md index 55deb8dac..8e3788e78 100644 --- a/bugs.md +++ b/bugs.md @@ -727,6 +727,16 @@ options used, seemingly, it has to write to disk the tarball which seems to defeat the purpose. This would ideally be fixed. +## 1990 tbr + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [1990/tbr/tbr.c](1990/tbr/tbr.c) +### Information: [1990/tbr/README.md](1990/tbr/README.md) + +The authors provided a list of features in the +[BUGS](/1990/tbr/README.md#bugs) section in their remarks. + + ## 1990 theorem ### STATUS: INABIAF - please **DO NOT** fix From 2bdf97ec41aea3687f708657d36f06a951ccbb0c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:51:14 -0800 Subject: [PATCH 11/12] Add 1990/theorem/try.sh This script shows not just theorem but the sorter and the Fibonacci generator as well. For the sorter it reverses output of ls (redirected to a file) and then shows how using sorter on it results in the same output of ls (with no options specified). Of course if different ls sorts output differently this could fail but I did not think of that until after I wrote it. --- 1990/theorem/Makefile | 2 +- 1990/theorem/README.md | 17 ++++------ 1990/theorem/try.sh | 76 ++++++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 3 ++ 4 files changed, 86 insertions(+), 12 deletions(-) create mode 100755 1990/theorem/try.sh diff --git a/1990/theorem/Makefile b/1990/theorem/Makefile index cb3aec200..9f9b30157 100644 --- a/1990/theorem/Makefile +++ b/1990/theorem/Makefile @@ -42,7 +42,7 @@ CSILENCE= -Wno-deprecated-declarations -Wno-empty-body -Wno-error -Wno-unused-va -Wno-implicit-function-declaration -Wno-incompatible-pointer-types \ -Wno-macro-redefined -Wno-parentheses -Wno-return-type -Wno-unused-parameter \ -Wno-empty-translation-unit -Wno-deprecated-non-prototype -Wno-int-conversion \ - -Wno-strict-prototypes + -Wno-strict-prototypes -Wno-implicit-int # Common C compiler warning flags # diff --git a/1990/theorem/README.md b/1990/theorem/README.md index 6969d78a5..351a1adc9 100644 --- a/1990/theorem/README.md +++ b/1990/theorem/README.md @@ -36,20 +36,10 @@ y1 - initial value (y(x1) == y1) ### Try: ```sh -./theorem y 0 1 0.1 1 +./try.sh ``` -If the two args passed to `fibonacci` and `theorem_bkp` add to 0 it will -print 0 over and over again in an infinite loop. In this case it should not be -fixed (another condition where this occurred was fixed in 2023 as it affected -usability of the program). -This is supposed to happen. As is written in the -[The Jargon File](http://catb.org/jargon/html/F/feature.html): - -``` -That's not a bug, that's a feature. -``` ## Judges' remarks: @@ -113,6 +103,11 @@ make fibonacci ./fibonacci 2 1 ``` +NOTE: if the two args passed to `fibonacci` and `theorem_bkp` add to 0 it will +print 0 over and over again in an infinite loop. In this case it should not be +fixed (another condition where this occurred was fixed in 2023 as it affected +usability of the program). + Program available on 9 track and cartridge cassette. Neither [Ginsu knife](https://ginsu.com) nor [Swiss army knife](https://en.wikipedia.org/wiki/Swiss_Army_knife) included! :-) diff --git a/1990/theorem/try.sh b/1990/theorem/try.sh new file mode 100755 index 000000000..4a38fca89 --- /dev/null +++ b/1990/theorem/try.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1990/theorem +# + +# 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: ./theorem y 0 1 0.1 1: " +echo 1>&2 +./theorem y 0 1 0.1 1 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./theorem x 1 2 0.1 2: " +echo 1>&2 +./theorem x 1 2 0.1 2 +echo 1>&2 + +echo "$ ./theorem -r 0 0 0 0 < theorem.c > sorter.c" 1>&2 +./theorem -r 0 0 0 0 < theorem.c > sorter.c +echo "$ make sorter" 1>&2 +make sorter +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ls | ./sorter > ls.sorted.txt: " +echo 1>&2 +# SC2012 (info): Use find instead of ls to better handle non-alphanumeric filenames. +# shellcheck disable=SC2012 +ls | ./sorter > ls.sorted.txt + +read -r -n 1 -p "Press any key to run: ls -r > ls.txt: " +echo 1>&2 +ls -r > ls.txt +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./sorter < ls.txt: " +echo 1>&2 +./sorter < ls.txt +echo 1>&2 + +read -r -n 1 -p "./sorter < ls.txt > ls.sorted.2.txt: " +echo 1>&2 +./sorter < ls.txt > ls.sorted.2.txt +echo 1>&2 + +read -r -n 1 -p "Press any key to show diff between ls.sorted.2.txt and ls.sorted.txt: " +echo 1>&2 +diff -s ls.sorted.2.txt ls.sorted.txt +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./sorter 0 0 0 0 < theorem.c > fibonacci.c: " +./sorter 0 0 0 0 < theorem.c > fibonacci.c +echo "$ make fibonacci" 1>&2 +make fibonacci + +read -r -n 1 -p "Press any key to run: ./fibonacci 1 7: " +echo 1>&2 +./fibonacci 1 7 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./fibonacci 2 5: " +echo 1>&2 +./fibonacci 2 5 +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index 78de83f87..7507f6b7b 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -1111,6 +1111,9 @@ with clang in Linux but which was defaulting to an error. This way was the simplest way to deal with the problem in question due to the way the entry works. +Cody also added the [try.sh](/1990/theorem/try.sh) script which shows the +original program and some of the programs it generates. + [Yusuke](#yusuke) pointed out that `atof` nowadays needs `#include ` which was used in order to get this to work initially (prior to this output was there but incomplete). From 36c9def8acc4fd57b14bc594cd0aab2634e30a90 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:59:23 -0800 Subject: [PATCH 12/12] Add 1990/westley/try.sh --- 1990/westley/README.md | 5 +---- 1990/westley/try.sh | 36 ++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 2 ++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100755 1990/westley/try.sh diff --git a/1990/westley/README.md b/1990/westley/README.md index 0dd814767..6b6e56705 100644 --- a/1990/westley/README.md +++ b/1990/westley/README.md @@ -17,10 +17,7 @@ The number should be greater than 0. ### Try: ```sh -./westley 1 -./westley 2 -./westley 3 -./westley 5 +./try.sh ``` diff --git a/1990/westley/try.sh b/1990/westley/try.sh new file mode 100755 index 000000000..29e8916d6 --- /dev/null +++ b/1990/westley/try.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1990/westley +# + +# 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: ./westley 1: " +echo 1>&2 +./westley 1 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./westley 2: " +echo 1>&2 +./westley 2 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./westley 3: " +echo 1>&2 +./westley 3 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./westley 5: " +echo 1>&2 +./westley 5 +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index 7507f6b7b..ef469ed47 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -1141,6 +1141,8 @@ often be the same (for the purpose of `clang`?). He also fixed the code to not enter an infinite loop if arg is a number not > 0 and to not crash if no arg is specified. +Cody also added the [try.sh](/1990/westley/try.sh) script. + The alt code did NOT have arg checks added as it is actually a copy of the original code.