From 3267c2e6250d8cbebf64861fb34b4be49f27bdd7 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 12 Jan 2024 08:36:04 -0800 Subject: [PATCH] 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]))