From 5cbf43230ccfa339de214d9e36d0fc10cfa59abb Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 02:30:57 -0800 Subject: [PATCH 01/12] Fix 2013/endoh3 for shellcheck Even though the author used 'cat file | ...' use the form './endoh3 < file | ...' rather than have to disable the shellcheck warning about useless cat. In some cases using it does simplify the command but not much in this case (though I still say there's no such thing as a useless cat: besides offering endless joy and wonder how else would we EVER know that the Earth is not flat if we didn't have cats to push everything off flat surfaces? :-) .. I mean besides lots of science to back it up, that is :-) ). --- 2013/endoh3/try.sh | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/2013/endoh3/try.sh b/2013/endoh3/try.sh index 02606cd4c..39586e6b2 100755 --- a/2013/endoh3/try.sh +++ b/2013/endoh3/try.sh @@ -32,43 +32,22 @@ endoh3() fi if [[ -f "$1" && -r "$1" ]]; then if [[ -n "$SOX" ]]; then - echo "$ cat $1 | ./endoh3 | $SOX -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio" 1>&2 + echo "$ ./endoh3 < $1 | $SOX -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio" 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 - # The author suggested the form below and it simplifies the command - # as well so we disable the supposed useless cat (there are no - # useless cats). - # - # SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. - # https://www.shellcheck.net/wiki/SC2002 - # shellcheck disable=SC2002 - cat "$1" | ./endoh3 | "$SOX" -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio + ./endoh3 < "$1" | "$SOX" -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio echo 1>&2 elif [[ -n "$PADSP" ]]; then - echo "$ cat $1 | ./endoh3 | $PADSP tee /dev/dsp > /dev/null" 1>&2 + echo "$ ./endoh3 < $1 | $PADSP tee /dev/dsp > /dev/null" 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 - # The author suggested the form below and it simplifies the command - # as well so we disable the supposed useless cat (there are no - # useless cats). - # - # SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. - # https://www.shellcheck.net/wiki/SC2002 - # shellcheck disable=SC2002 - cat "$1" | ./endoh3 | "$PADSP" tee /dev/dsp > /dev/null + ./endoh3 < "$1" | "$PADSP" tee /dev/dsp > /dev/null echo 1>&2 elif [[ -n "$RUBY" ]]; then - echo "$ cat $1 | ./endoh3 | $RUBY wavify.rb > $1.wav" 1>&2 + echo "$ ./endoh3 < $1 | $RUBY wavify.rb > $1.wav" 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 - # The author suggested the form below and it simplifies the command - # as well so we disable the supposed useless cat (there are no - # useless cats). - # - # SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. - # https://www.shellcheck.net/wiki/SC2002 - # shellcheck disable=SC2002 - cat "$1" | ./endoh3 | "$RUBY" wavify.rb > "$1".wav + ./endoh3 < "$1" | "$RUBY" wavify.rb > "$1".wav echo "Now try playing $1.wav in a program that plays WAV files." 1>&2 echo 1>&2 else From 42108882120bf98a536fae050fbf74248a3b312e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 08:15:10 -0800 Subject: [PATCH 02/12] Add 2014/vik/try.sh, update bugs.md, fix clobber The bugs.md has more details on the bug I discovered when working on 2020/ferguson2. Even the usage in the try section (now in try.sh) resulted in files that cannot be translated to English right. The make clobber rule now removes *.raw instead of specific raw files. This is important for clean up prior to updating the manifest. Updated .gitignore. --- 2014/vik/.gitignore | 2 +- 2014/vik/Makefile | 2 +- 2014/vik/README.md | 8 +++--- 2014/vik/try.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++ bugs.md | 47 +++++++++++++++++++++++++----- thanks-for-help.md | 6 +++- 6 files changed, 121 insertions(+), 14 deletions(-) create mode 100755 2014/vik/try.sh diff --git a/2014/vik/.gitignore b/2014/vik/.gitignore index b05374ba7..f32fab0f9 100644 --- a/2014/vik/.gitignore +++ b/2014/vik/.gitignore @@ -8,4 +8,4 @@ indent.o prog prog.alt prog.orig -prog.raw +*.raw diff --git a/2014/vik/Makefile b/2014/vik/Makefile index 5592fa8ac..306410c43 100644 --- a/2014/vik/Makefile +++ b/2014/vik/Makefile @@ -203,7 +203,7 @@ clean: clobber: clean ${RM} -f ${TARGET} ${ALT_TARGET} ${RM} -rf *.dSYM - ${RM} -f audio_file.raw prog.raw + ${RM} -f *.raw @-if [ -e sandwich ]; then \ ${RM} -f sandwich; \ echo 'ate sandwich'; \ diff --git a/2014/vik/README.md b/2014/vik/README.md index 04f0a0b0e..9c87e15fe 100644 --- a/2014/vik/README.md +++ b/2014/vik/README.md @@ -23,16 +23,16 @@ For more detailed information see [2014 vik in bugs.md](/bugs.md#2014-vik). ## To use: ```sh -./prog > foo.c +echo foo | ./prog > audio_file.raw + +echo foo | ./prog | mplayer -demuxer rawaudio - ``` ## Try: ```sh -echo 'Want to hear me beep?' | ./prog > audio_file.raw - -echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio - +./try.sh ``` diff --git a/2014/vik/try.sh b/2014/vik/try.sh new file mode 100755 index 000000000..2d505cee8 --- /dev/null +++ b/2014/vik/try.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2014/vik +# + +# 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 + +# remove target files for saving them +rm -f beep.raw chocolate.raw + +write_to_raw() +{ + if [[ "$#" -ne 2 ]]; then + echo "$0: usage: write_to_raw file arg" 1>&2 + return + fi + + read -r -n 1 -p "Press any key to run: echo $2 | ./prog > $1.raw: " + echo "$2" | ./prog > "$1".raw +} + +# now determine if we have mplayer(1) +MPLAYER="$(type -P mplayer)" +if [[ -n "$MPLAYER" ]]; then + read -r -n 1 -p "Press any key to play: 'Want to hear me beep?': " + echo 1>&2 + echo "$ echo 'Want to hear me beep?' | ./prog | mplayer -demuxer rawaudio -" 1>&2 + echo 'Want to hear me beep?' | ./prog | mplayer -demuxer rawaudio - + echo 1>&2 + read -r -n 1 -p "Press any key to run: ./prog e < beep.raw: " + echo 1>&2 + ./prog e < beep.raw + echo 1>&2 + + read -r -n 1 -p "Press any key to play: 'No. I want chocolate!': " + echo 1>&2 + echo "$ echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio - | tee chocolate.raw" 1>&2 + echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio - | tee chocolate.raw + read -r -n 1 -p "Press any key to run: ./prog e < chocolate.raw: " + echo 1>&2 +fi + +read -r -n 1 -p "Press any key to run: echo 'Want to hear me beep?' | ./prog > beep.raw: " +echo 1>&2 +echo 'Want to hear me beep?' | ./prog > beep.raw +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog e < beep.raw: " +echo 1>&2 +./prog e < beep.raw +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 'No. I want chocolate!' | ./prog > chocolate.raw: " +echo 1>&2 +echo 'No. I want chocolate!' | ./prog > chocolate.raw +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog e < chocolate.raw: " +echo 1>&2 +./prog e < chocolate.raw diff --git a/bugs.md b/bugs.md index 25d8d0b16..6969b7912 100644 --- a/bugs.md +++ b/bugs.md @@ -3199,17 +3199,50 @@ This program will very likely crash if no arg is given. ### Source code: [2014/vik/prog.c](2014/vik/prog.c) ### Information: [2014/vik/README.md](2014/vik/README.md) -[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) discovered a bug that -shows itself in some cases (it works in others) when working on his winning -[2020 Enigma machine](2020/ferguson2/prog.c) ('Most enigmatic') entry. See his -[README.md](2020/ferguson2/README.md) for details (search for `vik` in the -file). +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) discovered a bug to do +with translating sound to text that shows itself in some cases (it works in +others) when working on his winning [2020 Enigma machine](2020/ferguson2/prog.c) +('Most enigmatic') entry. See his [README.md](2020/ferguson2/README.md) for +details (search for `vik` in the file). This one might be more of a limitation +but this is not known. He provides a tip in testing the problem: it might help to use his Enigma machine to find problems as it will allow you to verify what is correct and what -is not. Again see his README.md for details! +is not. Again see his README.md for details. However it is also possible to not +rely on the entry as the below shows. One should be able to do: -If you want to try and fix this (mis)feature, you are welcome to try. + +```sh +echo 'No. I want chocolate!' | ./prog > chocolate.raw + +./prog e < chocolate.raw +``` + +and get: + +``` +No. I want some chocolate! +``` + +but instead we get: + +``` +IT FHOCOLITE! +``` + +which is very wrong. If however one does: + +``` +echo IOCCC | ./prog > ioccc.raw + +./prog e < ioccc.raw +``` + +they will properly get: + +``` +IOCCC +``` # 2015 diff --git a/thanks-for-help.md b/thanks-for-help.md index 3ee1fb2fe..3c3d2c855 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4182,7 +4182,11 @@ clean`) removes those files and so that they are ignored by `.gitignore`. ## [2014/vik](/2014/vik/prog.c) ([README.md](/2014/vik/README.md)) -[Cody](#cody) added an alternate version that is based on the author's remarks that will +[Cody](#cody) added the [try.sh](/2014/vik/try.sh) script. Cody notes that there +is a bug that will show itself as one of the features does not work right. The +translation of the raw audio to text is buggy in some cases. + +Cody also added an alternate version that is based on the author's remarks that will theoretically work for Microsoft Windows compilers (if anything works in Windows :-) ). We have no way of testing this and if anything has changed since 2014 that would break it we do not know. From e494259c75072abfcbc89ece0f98ab718b830652 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 08:59:08 -0800 Subject: [PATCH 03/12] Improve 2015/burton/try.sh The thanks file was updated slightly but it still needs some work. This will have to happen another time. --- 2015/burton/try.sh | 47 ++++++++++++++++++++++++++++------------------ thanks-for-help.md | 6 +++--- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/2015/burton/try.sh b/2015/burton/try.sh index e57857cdb..528f8307b 100755 --- a/2015/burton/try.sh +++ b/2015/burton/try.sh @@ -15,41 +15,52 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ ./calc '?0x3343<<2'" 1>&2 +read -r -n 1 -p "Press any key to run: ./calc '?0x3343<<2': " +echo 1>&2 ./calc '?0x3343<<2' +echo 1>&2 -echo "$ echo '?0x3343<<2' | ./ecalc" 1>&2 +read -r -n 1 -p "Press any key to run: echo '?0x3343<<2' | ./ecalc: " +echo 1>&2 echo '?0x3343<<2' | ./ecalc - - -echo "$ grep '[0-9]' prog.c" 1>&2 -read -r -n 1 -p "Press any key to continue (notice how there are no digits!): " -echo 1>&2 -grep -c '[0-9]' prog.c - -read -r -n 1 -p "Press any key to run: ./calc < test.in: " -echo 1>&2 -./calc < test.in echo 1>&2 -read -r -n 1 -p "Press any key to show try.this.txt: " + +read -r -n 1 -p "Press any key to run: grep '[0-9]' prog.c || echo \"no digits in prog.c!\": " echo 1>&2 -cat try.this.txt +grep -q '[0-9]' prog.c || echo "no digits in prog.c!" +echo 1>&2 + +read -r -n 1 -p "Press any key to show calc.in (space = next page, q = quit): " +echo 1>&2 +less -rEXFK test.in +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./calc < test.in (space = next page, q = quit): " +echo 1>&2 +./calc < test.in | less -rEXFK +echo 1>&2 + +read -r -n 1 -p "Press any key to show try.this.txt (space = next page, q = quit): " +echo 1>&2 +less -rEXFK try.this.txt echo 1>&2 read -r -n 1 -p "Press any key to run: ./calc < try.this.txt: " echo 1>&2 ./calc < try.this.txt -read -r -n 1 -p "Press any key to show the hex value of 42: " +read -r -n 1 -p "Press any key to run: ./calc 42 # show hex value of 42: " echo 1>&2 -echo "$ ./calc 42" 1>&2 ./calc 42 +echo 1>&2 -read -r -n 1 -p "Press any key to run: ./calc '1<<22-1' (show mask value for 22 bits): " +read -r -n 1 -p "Press any key to run: ./calc '1<<22-1' # show mask value for 22 bits: " echo 1>&2 ./calc '1<<22-1' +echo 1>&2 -read -r -n 1 -p "Press any key to run: ./calc ?0x11223344 (byte-swapped value of 0x11223344): " +read -r -n 1 -p "Press any key to run: ./calc ?0x11223344 # byte-swapped value of 0x11223344: " echo 1>&2 ./calc ?0x11223344 +echo 1>&2 diff --git a/thanks-for-help.md b/thanks-for-help.md index 3c3d2c855..73ff69c70 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -4229,9 +4229,9 @@ This was done for both the [prog.c](/2015/burton/prog.c) and [prog.alt.c](/2015/burton/prog.alt.c). The Makefile was also updated to build `eprog` and `eprog.alt` to make use of the feature more easily. Each is a new target (first in `TARGET` and second in `ALT_TARGET`) which have a prerequisite -of `${PROG}` and `${PROG}.alt` respectively and which copies `prog` and -`prog.alt` to `eprog` and `eprog.alt` respectively. With these changes now one -can easily use the echo feature the author implemented. +of `${PROG}` and `${PROG}.alt` respectively both of which also copy the `prog` +(`prog` or `eprog`) to the respective `eprog` (`eprog` or `eprog.alt`). With +these changes now one can easily use the echo feature the author implemented. Cody also added the [try.sh](/2015/burton/try.sh) script. This involved adding a text file, [try.this.txt](/2015/burton/try.this.txt). From 70bf6dd96a8a65391c40553e24f82d1c4240567e Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:10:44 -0800 Subject: [PATCH 04/12] Improve 2015/duble/try.sh --- 2015/duble/README.md | 4 ++++ 2015/duble/try.sh | 48 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/2015/duble/README.md b/2015/duble/README.md index 9c917b37f..26383a320 100644 --- a/2015/duble/README.md +++ b/2015/duble/README.md @@ -21,6 +21,10 @@ echo Some text | ./prog ./try.sh ``` +As the script says if you want to move to the next command at any point +(lorem-ipsum.txt takes a while to print in particular) you may do so by hitting +ctrl-c/sending intr. + ## Alternate code: diff --git a/2015/duble/try.sh b/2015/duble/try.sh index a6d75794a..79fa46aa1 100755 --- a/2015/duble/try.sh +++ b/2015/duble/try.sh @@ -15,24 +15,60 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ echo \"Hello, world!\" | ./prog" 1>&2 +# set it so that when program is terminated through various signals we re-enable +# the cursor +trap "tput cnorm;echo" 0 1 2 3 15 + +# temporarily disable cursor +tput civis + +echo "If you wish to move to the next command during the output of the current" 1>&2 +echo "you may send ctrl-c/intr to do so. This might be especially useful if you" 1>&2 +echo "get tired of watching lorem-ipsum.txt." 1>&2 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo \"Hello, world!\" | ./prog: " +echo 1>&2 echo "Hello, world!" | ./prog +echo 1>&2 -echo "$ echo \"IOCCC 2015\" | ./prog" 1>&2 +read -r -n 1 -p "Press any key to run: echo \"IOCCC 2015\" | ./prog: " +echo 1>&2 echo "IOCCC 2015" | ./prog +echo 1>&2 -echo "$ DRAFT=1 ./prog < prog.c" 1>&2 +read -r -n 1 -p "Press any key to show prog.c (space = next page, q = quit): " +echo 1>&2 +less -rEXFK prog.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: DRAFT=1 ./prog < prog.c: " +echo 1>&2 DRAFT=1 ./prog < prog.c +echo 1>&2 -echo "$ ./prog < prog.c" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog < prog.c: " +echo 1>&2 ./prog < prog.c +echo 1>&2 -echo "$ ./prog < lorem-ipsum.txt" 1>&2 +read -r -n 1 -p "Press any key to show lorem-ipsum.txt (space = next page, q = quit): " +echo 1>&2 +less -rEXFK lorem-ipsum.txt +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog < lorem-ipsum.txt: " +echo 1>&2 ./prog < lorem-ipsum.txt +echo 1>&2 echo "Type in text, hitting enter after each line." 1>&2 echo "Watch the output each time and try again." 1>&2 echo "Hit ctrl-c to exit." 1>&2 echo 1>&2 -echo "$ ./prog" 1>&2 +read -r -n 1 -p "Press any key to start: " +echo 1>&2 ./prog + +# make sure to re-enable cursor +tput cnorm From c09daf6a7d50368b4118a45daf18eee7be9857c6 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:34:40 -0800 Subject: [PATCH 05/12] Improve 2015/endoh2/try.sh --- 2015/endoh2/try.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/2015/endoh2/try.sh b/2015/endoh2/try.sh index 243663356..bfa0ad5e7 100755 --- a/2015/endoh2/try.sh +++ b/2015/endoh2/try.sh @@ -15,20 +15,28 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ cat prog.c" 1>&2 +read -r -n 1 -p "Press any key to run: cat prog.c: " +echo 1>&2 cat prog.c echo 1>&2 -echo "$ ./prog | diff -s - prog.c" -./prog | diff -s - prog.c +read -r -n 1 -p "Press any key to run: ./prog: " +echo 1>&2 +./prog echo 1>&2 -echo "$ less -EXF prog.c" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: less -rEXFK prog.c: " +echo 1>&2 less -EXF prog.c echo 1>&2 -echo "$ wc -c prog.c" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog | diff -s - prog.c: " +echo 1>&2 +./prog | diff -s - prog.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: wc -c prog.c: " +echo 1>&2 wc -c prog.c echo 1>&2 echo "Can you figure out the inconsistencies?" 1>&2 From 5f5657125e47059e71a2d027c3954b2899067db5 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:39:05 -0800 Subject: [PATCH 06/12] Improve 2015/endoh3/try.sh --- 2015/endoh3/try.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/2015/endoh3/try.sh b/2015/endoh3/try.sh index 43dceebe0..bdcd33a0b 100755 --- a/2015/endoh3/try.sh +++ b/2015/endoh3/try.sh @@ -13,24 +13,22 @@ fi # clear screen so that only the entry is shown clear -read -r -n 1 -p "Press any key to run: less -EXF prog.c (space = next page, q = quit): " +read -r -n 1 -p "Press any key to run: less -rEXFK prog.c (space = next page, q = quit): " echo 1>&2 less -EXF prog.c echo 1>&2 -echo "$ make future" 1>&2 +read -r -n 1 -p "Press any key to: make future: " +echo 1>&2 make future || exit 1 - echo 1>&2 echo 1>&2 echo "Will go back to the future and run 1984/mullender through prog. To quit" 1>&2 -echo "the program hit ctrl-c/intr." 1>&2 +echo "the program hit ctrl-c/intr. We suggest you try hitting enter or another" 1>&2 +echo "key when the output reaches the end of the line." 1>&2 echo 1>&2 -echo "You might want to try hitting enter or another key when the output reaches" 1>&2 -echo "the end of the line." 1>&2 echo 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: ./prog: " echo 1>&2 -echo "$ ./prog" 1>&2 ./prog From 1191c9c9de75293ae40662422830aa01d6cc99ca Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:45:36 -0800 Subject: [PATCH 07/12] Improve 2015/endoh4/try.sh --- 2015/endoh4/try.sh | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/2015/endoh4/try.sh b/2015/endoh4/try.sh index c06358f07..f73831734 100755 --- a/2015/endoh4/try.sh +++ b/2015/endoh4/try.sh @@ -15,44 +15,61 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear +# check if perl is installed (for later) PERL="$(type -P perl)" -echo "$ ./prog @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @: " +echo 1>&2 ./prog @ +echo 1>&2 -echo "$ ./prog @ @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @ @: " +echo 1>&2 ./prog @ @ +echo 1>&2 -echo "$ ./prog @ @ @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @ @ @: " +echo 1>&2 ./prog @ @ @ +echo 1>&2 -echo "$ ./prog @ @ @ @ @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @ @ @ @ @: " +echo 1>&2 ./prog @ @ @ @ @ +echo 1>&2 -echo "$ ./prog @ @ @ @ @ @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @ @ @ @ @ @: " +echo 1>&2 ./prog @ @ @ @ @ @ +echo 1>&2 -echo "$ ./prog @ @ @ @ @ @ @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @ @ @ @ @ @ @: " +echo 1>&2 ./prog @ @ @ @ @ @ @ +echo 1>&2 -echo "$ ./prog @ @ @ @ @ @ @ @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @ @ @ @ @ @ @ @: " +echo 1>&2 ./prog @ @ @ @ @ @ @ @ +echo 1>&2 -echo "$ ./prog @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @: " +echo 1>&2 ./prog @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ +echo 1>&2 -echo "$ ./prog @ @ @ @ @ @ @ @ @ @ @ @" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog @ @ @ @ @ @ @ @ @ @ @ @: " +echo 1>&2 ./prog @ @ @ @ @ @ @ @ @ @ @ @ +echo 1>&2 -echo "$ ./prog \"\$(< Makefile)\"" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: ./prog \"\$(< Makefile)\": " echo 1>&2 ./prog "$(< Makefile)" +echo 1>&2 if [[ -n "$PERL" ]]; then - echo "$ ./prog \$($PERL -e 'print "@ " x (2*3*5*7);')" 1>&2 - read -r -n 1 -p "Press any key to continue: " + read -r -n 1 -p "Press any key to run: ./prog \"\$($PERL -e 'print \"@ \" x (2*3*5*7);')\": " echo 1>&2 ./prog "$($PERL -e 'print "@ " x (2*3*5*7);')" fi - From c076836243dbe763ced620c8c5560cb67fbd74b2 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:53:09 -0800 Subject: [PATCH 08/12] Improve 2015/hou/try.sh --- 2015/hou/README.md | 2 +- 2015/hou/try.sh | 37 +++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/2015/hou/README.md b/2015/hou/README.md index 6affa98a7..939cde2c8 100644 --- a/2015/hou/README.md +++ b/2015/hou/README.md @@ -27,7 +27,7 @@ echo something | ./prog ## Try: ```sh -echo "" | ./prog +./try.sh ``` diff --git a/2015/hou/try.sh b/2015/hou/try.sh index 6fadf04b5..d7fff0a5f 100755 --- a/2015/hou/try.sh +++ b/2015/hou/try.sh @@ -16,30 +16,47 @@ make CC="$CC" all >/dev/null || exit 1 clear -echo "$ echo IOCCC | ./prog" 1>&2 +read -r -n 1 -p "Press any key to run: echo IOCCC | ./prog: " +echo 1>&2 echo IOCCC | ./prog echo 1>&2 -echo "$ ./prog < rfc1321.txt" 1>&2 -./prog < rfc1321.txt +read -r -n 1 -p "Press any key to run: head -n 13 rfc1321.txt (space = next page, q = quit): " +echo 1>&2 +head rfc1321.txt -n 13 | less -rEXFK echo 1>&2 -echo "$ echo \"\" | ./prog" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog < rfc1321.txt: " +echo 1>&2 +./prog < rfc1321.txt | less -rEXFK +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo \"\" | ./prog: " +echo 1>&2 echo "" | ./prog echo 1>&2 -echo "For the next two, observe the magical values: " -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to show prog.c (space = next page, q = quit): " +echo 1>&2 +less -rEXFK prog.c +echo 1>&2 + +echo "For the next two, observe the magical values." +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./prog < prog.c | cut -c-5: " echo 1>&2 -echo "$ ./prog < prog.c | cut -c-5" 1>&2 ./prog < prog.c | cut -c-5 -echo "$ ./prog < Makefile | cut -c-4" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog < Makefile | cut -c-4: " +echo 1>&2 ./prog < Makefile | cut -c-4 echo 1>&2 -echo "$ wc -c large" 1>&2 +read -r -n 1 -p "Press any key to run: wc -c large: " +echo 1>&2 wc -c large +echo 1>&2 -echo "$ ./prog < large" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog < large: " +echo 1>&2 ./prog < large From 9e60b74e72f2acdbd62bc05a5f7b2c09a3844d1a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:05:23 -0800 Subject: [PATCH 09/12] Improve 2015/howe/try.sh and fix make clobber The make clobber rule now removes *.tmp instead of just specific .tmp files. Updated .gitignore: removed the foo.tmp globs and added *.tmp. --- 2015/howe/.gitignore | 21 +----------- 2015/howe/Makefile | 2 +- 2015/howe/try.sh | 76 ++++++++++++++++++++++++++++++++++++++------ 3 files changed, 68 insertions(+), 31 deletions(-) diff --git a/2015/howe/.gitignore b/2015/howe/.gitignore index c9fb162fb..ece1baa0a 100644 --- a/2015/howe/.gitignore +++ b/2015/howe/.gitignore @@ -1,31 +1,12 @@ # # sort with: sort -d -u -123.tmp -1.tmp -ABCABBA.tmp -ABCDEFGHIJK.tmp -ABCDEF.tmp -ABCDE.tmp -ABCD.tmp -ABCEFGIJKDEFGHIJK.tmp -ABD.tmp -ABXYEFCD.tmp -ACBDEACBED.tmp -ACDBECFD.tmp -ACEBDABBABED.tmp -A.tmp -CBABAC.tmp -EMPTY.tmp -curds.tmp *.dSYM indent indent.c indent.o makeholes -nuked.tmp -patch.tmp prog prog.alt prog.orig +*.tmp war-and-peace.txt -whey.tmp diff --git a/2015/howe/Makefile b/2015/howe/Makefile index 29ed53eb4..40fecbde9 100644 --- a/2015/howe/Makefile +++ b/2015/howe/Makefile @@ -214,7 +214,7 @@ clean: clobber: clean ${RM} -f ${TARGET} ${ALT_TARGET} ${RM} -rf *.dSYM - ${RM} -f curds.tmp nuked.tmp whey.tmp makeholes + ${RM} -f makeholes *.tmp @-if [ -e sandwich ]; then \ ${RM} -f sandwich; \ echo 'ate sandwich'; \ diff --git a/2015/howe/try.sh b/2015/howe/try.sh index 249694d38..e5f82d0f6 100755 --- a/2015/howe/try.sh +++ b/2015/howe/try.sh @@ -16,22 +16,78 @@ make CC="$CC" all >/dev/null || exit 1 clear +read -r -n 1 -p "Press any key to run: ./prog prog.alt.c prog.c: " +echo 1>&2 ./prog prog.alt.c prog.c +echo 1>&2 -make test +read -r -n 1 -p "Press any key to run: make test (space = next page, q = quit): " +echo 1>&2 +make test | less -rEXFK +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog -d ABXYEFCD.tmp ACDBECFD.tmp: " +echo 1>&2 ./prog -d ABXYEFCD.tmp ACDBECFD.tmp +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog ABXYEFCD.tmp ACDBECFD.tmp: " +echo 1>&2 ./prog ABXYEFCD.tmp ACDBECFD.tmp +echo 1>&2 rm -f curds.tmp whey.tmp -cp -f cc.1 curds.tmp -cp -f cc.1 whey.tmp -chmod 666 whey.tmp -make makeholes -./makeholes -n 1000 whey.tmp -./prog curds.tmp whey.tmp -./avgtime.sh 100 ./prog curds.tmp whey.tmp +read -r -n 1 -p "Press any key to run: cp -vf cc.1 curds.tmp: " +echo 1>&2 +cp -vf cc.1 curds.tmp +echo 1>&2 +read -r -n 1 -p "Press any key to run: cp -vf cc.1 whey.tmp: " +echo 1>&2 +cp -vf cc.1 whey.tmp -cp -f war-and-peace.txt nuked.tmp +read -r -n 1 -p "Press any key to run: chmod -v 666 whey.tmp: " +echo 1>&2 +chmod -v 666 whey.tmp +echo 1>&2 + +if [[ ! -x makeholes ]]; then + read -r -n 1 -p "Press any key to run: make makeholes: " + echo 1>&2 + make makeholes + echo 1>&2 +fi + +read -r -n 1 -p "Press any key to run: ./makeholes -n 1000 whey.tmp: " +echo 1>&2 +./makeholes -n 1000 whey.tmp +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog curds.tmp whey.tmp (space = next page, q = quit): " +echo 1>&2 +./prog curds.tmp whey.tmp | less -rEXFK +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./avgtime.sh 100 ./prog curds.tmp whey.tmp: " +echo 1>&2 +./avgtime.sh 100 ./prog curds.tmp whey.tmp +echo 1>&2 + +read -r -n 1 -p "Press any key to run: cp -vf war-and-peace.txt nuked.tmp: " +echo 1>&2 +cp -vf war-and-peace.txt nuked.tmp +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./makeholes -c'~' -n 1000 nuked.tmp: " +echo 1>&2 ./makeholes -c'~' -n 1000 nuked.tmp -./prog war-and-peace.txt nuked.tmp +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./prog war-and-peace.txt nuked.tmp (space = next page, q = quit): " +echo 1>&2 +./prog war-and-peace.txt nuked.tmp | less -rEXFK +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp: " +echo 1>&2 ./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp +echo 1>&2 From bf35aeee783ed062764e66cc52ea815e066895b8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:12:23 -0800 Subject: [PATCH 10/12] Minor update to 2015/schweikhardt/try.sh Make less options -rEXFK. Not strictly necessary but it makes it more consistent with others. --- 2015/schweikhardt/try.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/2015/schweikhardt/try.sh b/2015/schweikhardt/try.sh index 02ae31192..ad513eb3b 100755 --- a/2015/schweikhardt/try.sh +++ b/2015/schweikhardt/try.sh @@ -20,32 +20,32 @@ echo "$ ./prog 19" 1>&2 read -r -n 1 -p "Press any key to run: ./prog 2410 (space = next page, q = quit): " echo 1>&2 -./prog 2410 | less -EXF +./prog 2410 | less -rEXFK read -r -n 1 -p "Press any key to run: ./prog abfff (space = next page, q = quit): " echo 1>&2 -./prog abfff | less -EXF +./prog abfff | less -rEXFK read -r -n 1 -p "Press any key to run: ./prog 27f8cebf (space = next page, q = quit): " echo 1>&2 -./prog 27f8cebf | less -EXF +./prog 27f8cebf | less -rEXFK read -r -n 1 -p "Press any key to run: ./prog 246f8fddf (space = next page, q = quit): " echo 1>&2 -./prog 246f8fddf | less -EXF +./prog 246f8fddf | less -rEXFK read -r -n 1 -p "Press any key to run: ./prog 2e95ab51ffea9de (space = next page, q = quit): " echo 1>&2 -./prog 2e95ab51ffea9de | less -EXF +./prog 2e95ab51ffea9de | less -rEXFK read -r -n 1 -p "Press any key to run: ./prog e6a5c22fd7bde9f (space = next page, q = quit): " echo 1>&2 -./prog e6a5c22fd7bde9f | less -EXF +./prog e6a5c22fd7bde9f | less -rEXFK read -r -n 1 -p "Press any key to run: ./prog 1b7dd73a937485bf (space = next page, q = quit): " echo 1>&2 -./prog 1b7dd73a937485bf | less -EXF +./prog 1b7dd73a937485bf | less -rEXFK read -r -n 1 -p "Press any key to run: ./prog 7d3237680d190a77e53751b (space = next page, q = quit): " echo 1>&2 -./prog 7d3237680d190a77e53751b | less -EXF +./prog 7d3237680d190a77e53751b | less -rEXFK read -r -n 1 -p "Press any key to run: ./prog 302ab3d052fb87c06228d249581be0e4 (space = next page, q = quit): " echo 1>&2 -./prog 302ab3d052fb87c06228d249581be0e4 | less -EXF +./prog 302ab3d052fb87c06228d249581be0e4 | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run ./prog with a googol (10^100) (space = next page, q = quit): " echo 1>&2 -./prog 1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F10000000000000000000000000 | less -EXF +./prog 1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F10000000000000000000000000 | less -rEXFK From e67bc64d9c5d2c72517aedd4581fb07de9d25231 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:21:01 -0800 Subject: [PATCH 11/12] Improve 2015/muth/try.sh --- 2015/muth/try.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/2015/muth/try.sh b/2015/muth/try.sh index 022d3d441..6675da800 100755 --- a/2015/muth/try.sh +++ b/2015/muth/try.sh @@ -19,16 +19,15 @@ clear echo "$ make -B V=2 run" 1>&2 read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -make CC="${CC}" -B V=2 run | less -EXF +read -r -n 1 -p "Press any key to run: make CC=${CC} -B V=2 run (space = next page, q = quit): " echo 1>&2 +make CC="${CC}" -B V=2 run | less -rEXFK echo 1>&2 -echo "$ strings prog | grep '(,)'" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +read -r -n 1 -p "Press any key to run: strings prog | grep '(,)' (space = next page, q = quit): " echo 1>&2 strings prog | grep '(,)' | less -EXF echo 1>&2 -echo 1>&2 for h in machine*.h; do for t in tape*.h; do @@ -37,9 +36,8 @@ for h in machine*.h; do if [[ "$REPLY" == "q" || "$REPLY" == "Q" ]]; then exit 0 fi - echo 1>&2 - make -B MACHINE="$h" TAPE="$t" V=1 run - echo 1>&2 + + make CC="${CC}" -B MACHINE="$h" TAPE="$t" V=1 run echo 1>&2 done done From d39aebcb0e8d8465b977947e5f503fd8bbfa9beb Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:28:11 -0800 Subject: [PATCH 12/12] Improve 2015/mills2/try.sh --- 2015/mills2/try.sh | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/2015/mills2/try.sh b/2015/mills2/try.sh index f3a820bb8..213be2147 100755 --- a/2015/mills2/try.sh +++ b/2015/mills2/try.sh @@ -15,47 +15,51 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear - -echo "$ printf '000I\236\f\31H\260\240\301\203' > ioccc.Z" 1>&2 +read -r -n 1 -p "Press any key to run: printf '000I\236\f\31H\260\240\301\203' > ioccc.Z: " +echo 1>&2 printf '000I\236\f\31H\260\240\301\203' > ioccc.Z echo 1>&2 -echo "$ ./prog ioccc.Z" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog ioccc.Z: " +echo 1>&2 ./prog ioccc.Z echo 1>&2 -echo "$ dd bs=512 count=128 < /dev/urandom > test1" 1>&2 +read -r -n 1 -p "Press any key to run: dd bs=512 count=128 < /dev/urandom > test1: " +echo 1>&2 dd bs=512 count=128 < /dev/urandom > test1 echo 1>&2 -echo "$ compress < test1 > test1.Z" 1>&2 +read -r -n 1 -p "Press any key to run: compress < test1 > test1.Z: " +echo 1>&2 compress < test1 > test1.Z echo 1>&2 -echo "$ time ./prog test1.Z | cmp - test1" 1>&2 -time ./prog test1.Z | cmp - test1 +read -r -n 1 -p "Press any key to run: time ./prog test1.Z | diff -s - test1: " +echo 1>&2 +time ./prog test1.Z | diff -s - test1 echo 1>&2 -echo "$ dd bs=512 count=128 < /dev/zero > test2" 1>&2 +read -r -n 1 -p "Press any key to run: dd bs=512 count=128 < /dev/zero > test2: " +echo 1>&2 dd bs=512 count=128 < /dev/zero > test2 echo 1>&2 -echo "$ compress < test2 > test2.Z" 1>&2 +read -r -n 1 -p "Press any key to run: compress < test2 > test2.Z: " +echo 1>&2 compress < test2 > test2.Z echo 1>&2 -echo "$ time ./prog test2.Z | cmp - test2" 1>&2 -time ./prog test2.Z | cmp - test2 +read -r -n 1 -p "Press any key to run: time ./prog test2.Z | diff -s - test2: " +echo 1>&2 +time ./prog test2.Z | diff -s - test2 echo 1>&2 +read -r -n 1 -p "Press any key to run: ./prog ioccc_guidelines.txt.Z (space = next page, q = quit): " +echo 1>&2 +./prog ioccc_guidelines.txt.Z | less -rEXFK +echo 1>&2 -echo "$ ./prog ioccc_guidelines.txt.Z" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +read -r -n 1 -p "Press any key to run: ./prog ioccc_rules.txt.Z (space = next page, q = quit): " echo 1>&2 -./prog ioccc_guidelines.txt.Z | less -EXF - -echo 1>&2 -echo "$ ./prog ioccc_rules.txt.Z" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./prog ioccc_rules.txt.Z | less -EXF +./prog ioccc_rules.txt.Z | less -rEXFK