Merge pull request #1872 from xexyl/westley90-try

Add 1990/westley/try.sh
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2024-01-12 12:45:01 -08:00
commit e2a542bb58
23 files changed
+367 -73

No files matched your search

+7 -11
View File
@@ -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.
-2
View File
@@ -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
+5
View File
@@ -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
+6 -4
View File
@@ -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<<AP)` does).
whatever you wish, as long as it's a positive `int` (or evaluates to a positive
`int` like the default `(A<<AP)` does). Too high a value will likely cause the
program to fail and a negative value will cause a compilation error.
### Alternate use:
@@ -57,7 +58,8 @@ default `(A<<AP)` does).
P=5 ./try.alt.sh
```
NOTE: if you specify too high a value for `P` the program might fail.
NOTE: if you specify too high a value for `P` the program might fail. If you
specify a value < 0 it will fail to compile.
## Judges' remarks:
+6 -16
View File
@@ -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:
+41
View File
@@ -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
-3
View File
@@ -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
+2 -1
View File
@@ -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:
+27
View File
@@ -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
+1 -1
View File
@@ -15,7 +15,7 @@ echo foo bar | ./dg
### Try:
```sh
echo "to C or not to C" | ./dg
./try.sh
```
Executable
+38
View File
@@ -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
+25 -5
View File
@@ -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
+1
View File
@@ -7,3 +7,4 @@ indent.o
prog.orig
scjones
scjones.orig
scjones.tmp.c
+7
View File
@@ -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
+35
View File
@@ -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
+15 -10
View File
@@ -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.
+1 -1
View File
@@ -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
#
+6 -11
View File
@@ -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! :-)
+76
View File
@@ -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
+1 -4
View File
@@ -17,10 +17,7 @@ The number should be greater than 0.
### Try:
```sh
./westley 1
./westley 2
./westley 3
./westley 5
./try.sh
```
+36
View File
@@ -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
+13
View File
@@ -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
@@ -724,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
+18 -4
View File
@@ -810,8 +810,8 @@ script.
[Cody](#cody) fixed an infinite loop where the program would print the same thing over
and over again, flooding the screen. The problem is that there was a `for` loop
that by necessity had to not have an increment stage but only in the `if` path
(in the loop itself) did the pointer get updated.
that by necessity had to not have an increment stage but the pointer only got
updated in the `if` path (in the loop itself).
Cody also provided the [try.sh](/1989/ovdluhe/try.sh) script which runs the
program four times on three files to show the different output. It doesn't run
@@ -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.
## <a name="1989_tromp"></a>[1989/tromp](/1989/tromp/tromp.c) ([README.md](/1989/tromp/README.md]))
@@ -959,11 +961,13 @@ environmental variable; see the README.md for details.
## <a name="1990_baruch"></a>[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 <strike>no one</strike>
[very few](https://en.wikipedia.org/wiki/0)
@@ -1020,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.
## <a name="1990_jaw"></a>[1990/jaw](/1990/jaw/jaw.c) ([README.md](/1990/jaw/README.md]))
@@ -1050,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.
## <a name="1990_tbr"></a>[1990/tbr](/1990/tbr/tbr.c) ([README.md](/1990/tbr/README.md]))
@@ -1102,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 <stdlib.h>` which was
used in order to get this to work initially (prior to this output was there but
incomplete).
@@ -1129,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.