From 305361c003a369c9724518ee862ec7f66bfa46bc Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 04:41:57 -0800 Subject: [PATCH 01/15] Improve 1994/westley alt + to use etc. The to build/original build, to use/original use and try/original try sections have been changed in the README.md to be much more consistent and clearer (and detailed in some ways). The to run section (not the original run section as that one is not supposed to be compilable and is not compilable either) has './westley.alt' now as that will give you a message even right after running 'make clobber alt'. The alt code was changed in that blank lines were removed and (as a cosmetic change) the 'return 0;'s were changed to 'exit(0);'s. Originally the idea was to have 'int main()' be 'main()' (like the original in the #if 0..#else..#endif block) but this will trigger -Wimplicit-int and since one would not want to run a more complicated 'make' invocation (instead of a simple 'cc' invocation or at least a simpler one) it means the output is messed up with a warning. But using exit(0); is fine albeit with an additional #include. The try.alt.sh script now has an -o westley.alt and instead of running ./a.out it runs ./westley.alt. This makes it more like normal 'make alt' targets. The Makefile all target now has information about the alt build as it does not have the restrictions of column width, character tab length and wraparound. The .gitignore no longer has a.out in it. --- 1994/westley/.gitignore | 1 - 1994/westley/Makefile | 7 ++++ 1994/westley/README.md | 65 +++++++++++++++++++++++++++----------- 1994/westley/try.alt.sh | 38 +++++++++++----------- 1994/westley/westley.alt.c | 43 ++++++++++++------------- 5 files changed, 93 insertions(+), 61 deletions(-) diff --git a/1994/westley/.gitignore b/1994/westley/.gitignore index 8c43a732c..667dfb2a1 100644 --- a/1994/westley/.gitignore +++ b/1994/westley/.gitignore @@ -1,6 +1,5 @@ # # sort with: sort -d -u -a.out *.dSYM indent indent.c diff --git a/1994/westley/Makefile b/1994/westley/Makefile index 051910be9..8d83492cf 100644 --- a/1994/westley/Makefile +++ b/1994/westley/Makefile @@ -131,7 +131,14 @@ ${PROG}: ${PROG}.c @echo "=-=-=-=-=" @echo "NOTE: this entry has different compiler errors based on compilation line." @echo "The purpose is to find the right error message to win the game!" + @echo @echo "NOTE: your terminal should be set to 80 columns, 8 character tabs, and wraparound." + @echo "If you wish to avoid these restrictions try the alternate code with:" + @echo + @echo " make alt" + @echo + @echo "for the default messages and the specific cc -D options for the rest of the game." + @echo "See the README.md for details or the try.sh and try.alt.sh scripts." @echo "=-=-=-=-=" -${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} diff --git a/1994/westley/README.md b/1994/westley/README.md index 8af4e9ddd..e46903135 100644 --- a/1994/westley/README.md +++ b/1994/westley/README.md @@ -5,27 +5,44 @@ make alt ``` We recommend that you try the alternate version first as the original entry -requires (for good display) 80 columns and 8 character tabs with wraparound. The -alt code is the same as the original except that the original code used -`#include`s of files that do not exist to generate the messages (as compiler -errors) whereas the alt code uses `printf(3)`. The purpose of the game is to -escape the dungeon. For the original entry see [Original code](#original-code) -below. +requires (for better display) 80 columns and 8 character tabs with wraparound. + +The alt code uses the same logic as the original code except that the original +code used `#include`s of files that do not exist to generate the messages (as +compiler errors) whereas the alt code uses `printf(3)`. For the original entry +see [Original code](#original-code) below. ## To use: -There is no running as such. See below. + +```sh +./westley.alt +``` + +The purpose of the game is to escape the dungeon. Depending on the compiler line +you will get a different message when you run the program. One compiler line +will make you win the game (escape the dungeon) and others will show something +else. + +_This is independent of the previous (if there are any previous) compiler +invocations_ specified. That means with the right compiler invocation you can +'win' the game on the first go. + +There are a variety of different `-D` flags you give to `cc` that change the +message you get. You might wish to look at the [source code](westley.alt.c) to +get a better idea or see below in the [Try](#try) section for running the game +from start to finish. ### Try: -For something more interesting try compiling it with -different cc arguments and then run the program each time. For example: +For something more interesting try compiling it with different `cc -D` arguments +and then run the program each time. For example: ```sh -cc -Describe -Door westley.alt.c && ./a.out -cc -Describe -Drain westley.alt.c && ./a.out +cc -Describe -Door westley.alt.c -o westley.alt && ./westley.alt +cc -Describe -Drain westley.alt.c -o westley.alt && ./westley.alt ``` To see the game from start to finish, try: @@ -37,8 +54,8 @@ To see the game from start to finish, try: ## Original code: -NOTE: the purpose of this entry is to escape the dungeon via the compiler line -where you **get messages as compiler errors**. Depending on the compiler line you +The purpose of the game is to escape the dungeon **via the compiler line +where you get _messages as compiler errors_**. Depending on the compiler line you will get different error messages and one compiler line will make you win the game! @@ -53,19 +70,31 @@ reason that we recommend you try it first. make all ``` -Depending on the compilation line you will get different messages (as errors) -which let you play the game. +There are a variety of different `-D` flags you can give to `cc` that change the +message you get. You might wish to look at the [source code](westley.c) to get a +better idea or see below in the [Original try](#original-try) section for +running the game from start to finish. ## Original use: -There is no running as such. See below. +There is no running of this program directly as it is supposed to fail to +compile: the purpose of the game is to escape the dungeon but depending on the +compiler line you will get a different message (**as compiler errors** due to +`#include` files not existing). One compiler line will make you win the game +(escape the dungeon) and others will show something else. + +_This is independent of the previous (if there are any previous) compiler +invocations_ specified. That means with the right compiler invocation you can +'win' the game on the first go. But unlike the [alternate code](westley.alt.c), +you do not run this program as it will not compile: instead it will be compiler +error messages; there is no running the program. ## Original try: -For something more interesting try compiling it with -different cc arguments. For example: +For something more interesting try compiling it with different `cc -D` +arguments: ```sh cc -Describe -Door westley.c diff --git a/1994/westley/try.alt.sh b/1994/westley/try.alt.sh index 4ff548f14..ee023c6f1 100755 --- a/1994/westley/try.alt.sh +++ b/1994/westley/try.alt.sh @@ -9,55 +9,55 @@ if [[ -z "$CC" ]]; then CC="cc" fi -rm -f a.out -"${CC}" -Describe -Door westley.alt.c && ./a.out +rm -f westley.alt +"${CC}" -Describe -Door westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Describe -Drain westley.alt.c && ./a.out +"${CC}" -Describe -Drain westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Describe -Dwarf westley.alt.c && ./a.out +"${CC}" -Describe -Dwarf westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Describe -Debris westley.alt.c && ./a.out # or -Dungeon +"${CC}" -Describe -Debris westley.alt.c -o westley.alt && ./westley.alt # or -Dungeon sleep 1 echo 1>&2 -"${CC}" -Describe -Desk westley.alt.c && ./a.out +"${CC}" -Describe -Desk westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Describe -Dime westley.alt.c && ./a.out +"${CC}" -Describe -Dime westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Describe -Directory westley.alt.c && ./a.out +"${CC}" -Describe -Directory westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Dial -DUNgeon0614 westley.alt.c && ./a.out +"${CC}" -Dial -DUNgeon0614 westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Drink -Daiquiri westley.alt.c && ./a.out +"${CC}" -Drink -Daiquiri westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Drop -Daiquiri westley.alt.c && ./a.out +"${CC}" -Drop -Daiquiri westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Drop -Dwarf -Daiquiri westley.alt.c && ./a.out # or -Drop -Down -Daiquiri +"${CC}" -Drop -Dwarf -Daiquiri westley.alt.c -o westley.alt && ./westley.alt # or -Drop -Down -Daiquiri sleep 1 echo 1>&2 -"${CC}" -Describe -Document westley.alt.c && ./a.out +"${CC}" -Describe -Document westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Depress -Dotted -Dog westley.alt.c && ./a.out +"${CC}" -Depress -Dotted -Dog westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Depress -Dalmatian westley.alt.c && ./a.out # also accepts "Dalmation" [sic] +"${CC}" -Depress -Dalmatian westley.alt.c -o westley.alt && ./westley.alt # also accepts "Dalmation" [sic] sleep 1 echo 1>&2 -"${CC}" -Deposit -Dime westley.alt.c && ./a.out +"${CC}" -Deposit -Dime westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Drop -Donut westley.alt.c && ./a.out +"${CC}" -Drop -Donut westley.alt.c -o westley.alt && ./westley.alt sleep 1 echo 1>&2 -"${CC}" -Drop -Donut -Down -Drain westley.alt.c && ./a.out # or -Drop -Dwarf -Donut +"${CC}" -Drop -Donut -Down -Drain westley.alt.c -o westley.alt && ./westley.alt # or -Drop -Dwarf -Donut echo 1>&2 -rm -f a.out +rm -f westley.alt diff --git a/1994/westley/westley.alt.c b/1994/westley/westley.alt.c index 7efcf6438..37ec48fd4 100644 --- a/1994/westley/westley.alt.c +++ b/1994/westley/westley.alt.c @@ -1,4 +1,5 @@ -#include +#include +#include int main() { #if rop&onut&((own&rain)|warf) @@ -7,46 +8,46 @@ printf("The orc scrambles to the drain,\n" "run out the door and escape!\n" "\n" " The End\n"); -return 0; +exit(0); #else #if escribe #if ocument printf("It reads:\n" " Depress Dotted Dog\n"); -return 0; +exit(0); #else #if oor printf("The door is decorated with relief\n" "figures of various dog breeds.\n"); -return 0; +exit(0); #else #if rain printf("Through the drain you see a dwarf\n" "in another cell.\n"); -return 0; +exit(0); #else #if warf printf("The gnarled dwarf looks thirsty.\n"); -return 0; +exit(0); #else #if ungeon|ebris printf("You notice a desk, a phone, and\n" "a phone directory among the clutter.\n"); -return 0; +exit(0); #else #if esk printf("There are some dimes on the desk.\n"); -return 0; +exit(0); #else #if irectory printf("It reads:\n" " Pixie's Pub -\n" " instant service -\n" " Dial DUNgeon0614\n"); -return 0; +exit(0); #else printf("You notice nothing unusual.\n"); -return 0; +exit(0); #endif #endif #endif @@ -59,13 +60,13 @@ return 0; printf("Pixie takes your order, and\n" "magically, the room is filled\n" "with banana daiquiris.\n"); -return 0; +exit(0); #endif #if rink&aiquiri printf("As you drink, a voice from\n" "below says 'Could you drop\n" "one down here?'\n"); -return 0; +exit(0); #endif #if rop&aiquiri #if warf|own @@ -74,11 +75,11 @@ printf("The dwarf eagerly accepts\n" "I found this, but I can't\n" "understand it.' He hands\n" "you a document.\n"); -return 0; +exit(0); #else printf("You drop the drink\n" "on the floor.\n"); -return 0; +exit(0); #endif #endif #if epress&(almatian|almation) @@ -87,33 +88,29 @@ printf("As you press the dalmatian\n" "to reveal a menacing orc by\n" "a vending machine (with a\n" "sign reading 'DEPOSIT MONEY').\n"); -return 0; +exit(0); #endif #if eposit&(ime|imes) printf("Donuts spill out; you get\n" "some, the orc hungrily eats\n" "the rest.\n"); -return 0; - +exit(0); #endif #if rop&onut - printf("The orc quickly eats the\n" "donut; he still bars the\n" "way.\n"); - -return 0; +exit(0); #endif #if rop+epress+ime+eposit+rink+aiquiri+onut==1 - printf("Be more specific.\n"); -return 0; +exit(0); #endif printf("You are in a debris-filled\n" "dungeon; a door bars the\n" "way, and sludge trickles into\n" "a floor drain.\n"); -return 0; +exit(0); #endif #endif } From 28b03f9d97f82aa1111b2847cf86a6039ca2876f Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 05:09:57 -0800 Subject: [PATCH 02/15] Further improvements to 1996/gandalf/try.sh Running ./try.sh by itself will not show this improvement. It might be an inside joke between Landon and me but which adds fun to the entry in a way that many people will appreciate, given the entry name. Those who do not, however, will not be bothered by it as running ./try.sh won't do anything different from before: it'll just run the program in a variety of ways as before. --- 1996/gandalf/try.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/1996/gandalf/try.sh b/1996/gandalf/try.sh index b205fca90..01a2054c8 100755 --- a/1996/gandalf/try.sh +++ b/1996/gandalf/try.sh @@ -18,6 +18,21 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear +if [[ "$#" -gt 0 ]]; then + if [[ "${1@L}" = "gandalf" ]]; then + echo "It is perilous to try the patience of Gandalf!" 1>&2 + read -r -p "Are you sure you wish to do this (Y/N)? " + echo 1>&2 + if [[ "$REPLY" != "y" && "$REPLY" != "Y" ]]; then + echo "Wise move, will not try Gandalf's patience!" 1>&2 + exit 0 + else + echo "Fool of a ${USER@u}!" 1>&2 + echo 1>&2 + fi + fi +fi + # remove temporary files to show later rm -f hatcat.txt cathat.txt hatcat2.txt cathat2.txt hatcat3.txt cathat3.txt From bff24da897dd34763af7312dd86da399685c68e8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 05:20:51 -0800 Subject: [PATCH 03/15] Slight update to 1996/gandalf/try.sh --- 1996/gandalf/try.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/1996/gandalf/try.sh b/1996/gandalf/try.sh index 01a2054c8..b37d65d0e 100755 --- a/1996/gandalf/try.sh +++ b/1996/gandalf/try.sh @@ -28,6 +28,7 @@ if [[ "$#" -gt 0 ]]; then exit 0 else echo "Fool of a ${USER@u}!" 1>&2 + echo "Oh well, never mind that, moving on ..." 1>&2 echo 1>&2 fi fi From af05d9dac158829bccd9f5ef9b61f7d3c879d9ba Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 05:31:20 -0800 Subject: [PATCH 04/15] Slight UI improvements in 1996/gandalf/try.sh Rather than showing something like: Showing diff between 'cmd' and 'cmd': Press any key to run: diff ... it now shows instead (for example): $ diff hatcat.txt cathat.txt (diff between 'hatcat' and './cathat'): Press any key to continue: The reason it's two lines is because having it on one line makes it a kind long line. Probably not an issue with modern systems but I have tried to keep the lines close to 80 columns and not doing it this way would make it almost 90. The script now has -C 1 used to show context. This way the file names are shown in the output to help distinguish the files being compared. Of course it might be possible to diff the command outputs themselves but this works better because it will show the files that are the same (when they are) rather than '.. and - are identical'. --- 1996/gandalf/try.sh | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/1996/gandalf/try.sh b/1996/gandalf/try.sh index b37d65d0e..4acf4097a 100755 --- a/1996/gandalf/try.sh +++ b/1996/gandalf/try.sh @@ -41,13 +41,14 @@ trap 'rm -f hatcat.txt cathat.txt hatcat2.txt cathat2.txt hatcat3.txt cathat3.tx show_diff() { - if [[ "$#" -ne 2 ]]; then + if [[ "$#" -ne 3 ]]; then echo "$0: show_diff expects two args, got: $#" 1>&2 exit 1 fi - read -r -n 1 -p "Press any key to run: diff $1 $2: " + echo "$ diff $1 $2 ($3): " 1>&2 + read -r -n 1 -p "Press any key to continue: " echo 1>&2 - diff "$1" "$2" && echo "$1 and $2 are identical" + diff -C 1 "$1" "$2" && echo "$1 and $2 are identical" echo 1>&2 } @@ -72,8 +73,7 @@ echo 1>&2 cathat | tee cathat.txt echo 1>&2 -echo "Showing diff between the above two commands, 'hatcat' and './cathat':" 1>&2 -show_diff hatcat.txt cathat.txt +show_diff hatcat.txt cathat.txt "diff between 'hatcat' and './cathat'" read -r -n 1 -p "Press any key to run: ./hatcat | tee hatcat2.txt: " echo 1>&2 @@ -83,8 +83,7 @@ read -r -n 1 -p "Press any key to run: ./cathat | tee cathat2.txt: " echo 1>&2 ./cathat | tee cathat2.txt -echo "Showing diff between running 'hatcat' and './hatcat':" 1>&2 -show_diff hatcat.txt hatcat2.txt +show_diff hatcat.txt hatcat2.txt "diff between 'hatcat' and './hatcat'" read -r -n 1 -p "Press any key to run: \$(pwd)/cathat | tee cathat3.txt: " echo 1>&2 @@ -94,23 +93,17 @@ read -r -n 1 -p "Press any key to run: \$(pwd)/hatcat | tee hatcat3.txt: " echo 1>&2 "$(pwd)"/hatcat | tee hatcat3.txt -echo "Showing diff between running './hatcat' and './cathat':" 1>&2 -show_diff hatcat2.txt cathat2.txt +show_diff hatcat2.txt cathat2.txt "diff between './hatcat' and './cathat'" -echo "Showing diff between running '\$(pwd)/hatcat' and '\$(pwd)/cathat':" 1>&2 -show_diff hatcat3.txt cathat3.txt +show_diff hatcat3.txt cathat3.txt "diff between '\$(pwd)/hatcat' and '\$(pwd)/cathat'" -echo "Showing diff between running '\$(pwd)/hatcat' and 'hatcat':" 1>&2 -show_diff hatcat3.txt hatcat.txt +show_diff hatcat3.txt hatcat.txt "diff between '\$(pwd)/hatcat' and 'hatcat'" -echo "Showing diff between running '\$(pwd)/hatcat' and './hatcat':" 1>&2 -show_diff hatcat3.txt hatcat2.txt +show_diff hatcat3.txt hatcat2.txt "diff between '\$(pwd)/hatcat' and './hatcat'" -echo "Showing diff between running '\$(pwd)/cathat' and 'cathat':" 1>&2 -show_diff cathat3.txt cathat.txt +show_diff cathat3.txt cathat.txt "diff between \$(pwd)/cathat' and 'cathat'" -echo "Showing diff between running '\$(pwd)/cathat' and './cathat':" 1>&2 -show_diff cathat3.txt cathat2.txt +show_diff cathat3.txt cathat2.txt "diff between '\$(pwd)/cathat' and './cathat'" # remove temporary files rm -f hatcat.txt cathat.txt hatcat2.txt cathat2.txt hatcat3.txt cathat3.txt From 98c5834938ebacb0c99d03bcb96b9b55e742014c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 07:42:03 -0800 Subject: [PATCH 05/15] Improve 2011/akari/try.sh --- 2011/akari/try.sh | 74 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/2011/akari/try.sh b/2011/akari/try.sh index 98053a63a..08b81f79f 100755 --- a/2011/akari/try.sh +++ b/2011/akari/try.sh @@ -20,48 +20,86 @@ rm -f akari2 akari3 akari4 # clear screen after compilation so that only the entry is shown clear + +read -r -n 1 -p "Press any key to run: ./akari < example.ppm > odd_output.ppm: " +echo 1>&2 ./akari < example.ppm > odd_output.ppm +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./akari - - even < example.ppm > even_output.ppm: " +echo 1>&2 ./akari - - even < example.ppm > even_output.ppm +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./akari example.ppm odd_output.ppm: " +echo 1>&2 ./akari example.ppm odd_output.ppm - -make akari2 >/dev/null|| exit 1 -read -r -n 1 -p "Press any key to cat akari2.c: " -cat akari2.c echo 1>&2 -read -r -n 1 -p "Press any key to run: ./akari2 < akari2.c: " -./akari2 < akari2.c +read -r -n 1 -p "Press any key to run: make akari2 >/dev/null || exit 1: " +echo 1>&2 +make akari2 >/dev/null || exit 1 echo 1>&2 -read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari2.c: " -./akari2 rot13 < akari2.c +read -r -n 1 -p "Press any key to show akari2.c (space = next page, q = quit): " +echo 1>&2 +less -rEXF akari2.c +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./akari2 < akari2.c (space = next page, q = quit): " +echo 1>&2 +./akari2 < akari2.c | less -rEXF +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari2.c (space = next page, q = quit): " +echo 1>&2 +./akari2 rot13 < akari2.c | less -rEXF +echo 1>&2 + +read -r -n 1 -p "Press any key to run: make akari3 >/dev/null|| exit 1: " +echo 1>&2 make akari3 >/dev/null|| exit 1 +echo 1>&2 -read -r -n 1 -p "Press any key to cat akari3.c: " +read -r -n 1 -p "Press any key to show akari3.c: " +echo 1>&2 cat akari3.c echo 1>&2 read -r -n 1 -p "Press any key to run: ./akari3: " +echo 1>&2 ./akari3 echo 1>&2 +read -r -n 1 -p "Press any key to run: make akari4 >/dev/null|| exit 1: " +echo 1>&2 make akari4 >/dev/null|| exit 1 +echo 1>&2 -read -r -n 1 -p "Press any key to cat akari4.c: " +read -r -n 1 -p "Press any key to show akari4.c: " +echo 1>&2 cat akari4.c +echo 1>&2 read -r -n 1 -p "Press any key to run: ./akari4: " +echo 1>&2 ./akari4 echo 1>&2 -read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari.c | ./akari > rot13.c; cat rot13.c: " -./akari2 rot13 < akari.c | ./akari > rot13.c; cat rot13.c +echo "$ ./akari2 rot13 < akari.c | ./akari | tee rot13.c" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./akari2 rot13 < akari.c | ./akari | tee rot13.c | less -rEXF -read -r -n 1 -p "Press any key to run: ./akari2 < akari.c > expanded_output.txt: " -./akari2 < akari.c > expanded_output.txt -read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari.c > expanded_and_rot13_output.txt: " -./akari2 rot13 < akari.c > expanded_and_rot13_output.txt -read -r -n 1 -p "Press any key to cat expanded_and_rot13_output.txt: " -cat expanded_and_rot13_output.txt +echo "$ ./akari2 < akari.c | tee expanded_output.txt" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./akari2 < akari.c | tee expanded_output.txt | less -rEXF +echo 1>&2 + +echo "$ ./akari2 rot13 < akari.c | tee expanded_and_rot13_output.txt" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./akari2 rot13 < akari.c | tee expanded_and_rot13_output.txt | less -rEXF +echo 1>&2 From eaf74589ee2fe695dcb503fd42c923fad314a392 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 07:44:34 -0800 Subject: [PATCH 06/15] Improve 2011/borsanyi/try.sh --- 2011/borsanyi/try.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/2011/borsanyi/try.sh b/2011/borsanyi/try.sh index f5b2b4d7e..d7179056e 100755 --- a/2011/borsanyi/try.sh +++ b/2011/borsanyi/try.sh @@ -16,13 +16,16 @@ make CC="$CC" all >/dev/null || exit 1 clear -read -r -n 1 -p "Press any key to run: ./borsanyi < data.1: " -./borsanyi < data.1 +read -r -n 1 -p "Press any key to run: ./borsanyi < data.1 (space = next page, q = quit): " +echo 1>&2 +./borsanyi < data.1 | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to run: ./borsanyi < data.2: " -./borsanyi < data.2 +read -r -n 1 -p "Press any key to run: ./borsanyi < data.2 (space = next page, q = quit): " +echo 1>&2 +./borsanyi < data.2 | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to run: ./borsanyi < data.3: " -./borsanyi < data.3 +read -r -n 1 -p "Press any key to run: ./borsanyi < data.3 (space = next page, q = quit): " +echo 1>&2 +./borsanyi < data.3 | less -rEXF From d28bd0e54e527d5e929bd1dea1a0c44f131e0cf8 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 07:46:53 -0800 Subject: [PATCH 07/15] Improve 2011/dlowe/try.sh --- 2011/dlowe/try.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/2011/dlowe/try.sh b/2011/dlowe/try.sh index 57aa318bd..0b85a5dd2 100755 --- a/2011/dlowe/try.sh +++ b/2011/dlowe/try.sh @@ -18,35 +18,45 @@ make CC="$CC" all >/dev/null clear read -r -n 1 -p "Press any key to run: ./dlowe dlowe.c < dlowe-aux-data/ioccc-winlose-trained.net: " +echo 1>&2 ./dlowe dlowe.c < dlowe-aux-data/ioccc-winlose-trained.net echo 1>&2 read -r -n 1 -p "Press any key to run: ./dlowe dlowe < dlowe-aux-data/ioccc-winlose-trained.net: " +echo 1>&2 ./dlowe dlowe < dlowe-aux-data/ioccc-winlose-trained.net echo 1>&2 read -r -n 1 -p "Press any key to run: ./dlowe xor-0/00 < dlowe-aux-data/xor-trained.net: " +echo 1>&2 ./dlowe xor-0/00 < dlowe-aux-data/xor-trained.net echo 1>&2 read -r -n 1 -p "Press any key to run: ./dlowe xor-0/11 < dlowe-aux-data/xor-trained.net: " +echo 1>&2 ./dlowe xor-0/11 < dlowe-aux-data/xor-trained.net echo 1>&2 read -r -n 1 -p "Press any key to run: ./dlowe xor-1/01 < dlowe-aux-data/xor-trained.net: " +echo 1>&2 ./dlowe xor-1/01 < dlowe-aux-data/xor-trained.net echo 1>&2 read -r -n 1 -p "Press any key to run: ./dlowe xor-1/10 < dlowe-aux-data/xor-trained.net: " +echo 1>&2 ./dlowe xor-1/10 < dlowe-aux-data/xor-trained.net echo 1>&2 read -r -n 1 -p "Press any key to run: ./dlowe README.html < dlowe-aux-data/english-trained.net: " +echo 1>&2 ./dlowe README.html < dlowe-aux-data/english-trained.net echo 1>&2 read -r -n 1 -p "Press any key to run: ./dlowe dlowe-aux-data.tar.bz2 < dlowe-aux-data/png-trained.net: " +echo 1>&2 ./dlowe dlowe-aux-data.tar.bz2 < dlowe-aux-data/png-trained.net +echo 1>&2 -read -r -n 1 -p "Press any key to run: ./dlowe dlowe.c < dlowe-aux-data/ioccc-winlose-trained.net: " +read -r -n 1 -p "Press any key to run: ./dlowe dlowe.c < dlowe-aux-data/ioccc-winlose-trained.net: " +echo 1>&2 ./dlowe dlowe.c < dlowe-aux-data/ioccc-winlose-trained.net From 36ea689cea2b86fe1e666718c81d31f7b462c734 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 07:49:30 -0800 Subject: [PATCH 08/15] Improve try section in 2011/eastman --- 2011/eastman/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/2011/eastman/README.md b/2011/eastman/README.md index aeed05608..c83504819 100644 --- a/2011/eastman/README.md +++ b/2011/eastman/README.md @@ -11,10 +11,13 @@ make ./eastman ``` +NOTE: to restore your cursor in your shell, try `reset`. + ## Try: -Quit the program. Resize your terminal window. Run it again. +Run the program. Quit it (ctrl-c/intr). Resize your terminal window. Run it +again. Try doing this a number of times with different sizes each time. ```sh ./eastman From 6cb855f95c5a70fd1e4f5a15c844123978c7b7a2 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 07:58:15 -0800 Subject: [PATCH 09/15] Improve and fix 2011/fredriksson/try.sh The script now writes the output to a file (via tee(1)) and uses diff -s on the file and fredriksson.c. It also fixes a problem where if one were to hit space after the prompt (lines would be merged) rather than enter/return. Fixed shellcheck warning (no need to ignore it). --- 2011/fredriksson/.gitignore | 1 + 2011/fredriksson/try.sh | 33 ++++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/2011/fredriksson/.gitignore b/2011/fredriksson/.gitignore index 541280740..6a4c5f542 100644 --- a/2011/fredriksson/.gitignore +++ b/2011/fredriksson/.gitignore @@ -5,6 +5,7 @@ ag.c *.dSYM fredriksson fredriksson.orig +fredriksson.txt indent indent.c indent.o diff --git a/2011/fredriksson/try.sh b/2011/fredriksson/try.sh index 99e1e8154..c3f37edd5 100755 --- a/2011/fredriksson/try.sh +++ b/2011/fredriksson/try.sh @@ -15,17 +15,25 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear +# remove temporary file +rm -f fredriksson.txt -echo "$ ./fredriksson -k3 cat < fredriksson.c" 1>&2 -read -r -n 1 -p "Press any key to have the program show its source code: " +echo "$ ./fredriksson -k3 cat < fredriksson.c | tee fredriksson.txt" 1>&2 +read -r -n 1 -p "Press any key to have the program show its own code (space = next page, q = quit): " +echo 1>&2 +./fredriksson -k3 cat < fredriksson.c | tee fredriksson.txt | less -rEXF echo 1>&2 -./fredriksson -k3 cat < fredriksson.c -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: diff -s fredriksson.c fredriksson.txt: " echo 1>&2 -read -r -n 1 -p "Press any key to run: ./fredriksson -k1 -i POOT < /etc/group: " +diff -s fredriksson.c fredriksson.txt echo 1>&2 -./fredriksson -k1 -i POOT < /etc/group +rm -f fredriksson.txt + +echo "$ ./fredriksson -k1 -i POOT < /etc/group" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./fredriksson -k1 -i POOT < /etc/group | less -rEXF echo 1>&2 read -r -n 1 -p "Press any key to run: ./fredriksson -ck0 [0-9] < fredriksson.c: " @@ -36,12 +44,15 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./fredriksson -ck0 [0-9] < ag.c: " echo 1>&2 ./fredriksson -ck0 [0-9] < ag.c +echo 1>&2 -echo "Trying to set unlimited stack space for this process..." 1>&2 -ulimit -s unlimited 2>/dev/null -if [[ "$?" -ne 0 ]]; then - echo "...couldn't set unlimited stack space, will skip command." 1>&2 +if ! ulimit -s unlimited 2>/dev/null; then + echo "Couldn't set unlimited stack space, skipping next command." 1>&2 else - read -r -n 1 -p "Press any key to run: ./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words: " + echo "Set unlimited stack space, continuing." 1>&2 + echo 1>&2 + echo "$ ./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + echo 1>&2 ./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words fi From 8b28b531387d7b7c1d09dc12a02e26464b69a9f1 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:01:32 -0800 Subject: [PATCH 10/15] Improve/fix 2011/goren/try.sh --- 2011/goren/try.sh | 6 +++++- thanks-for-help.md | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/2011/goren/try.sh b/2011/goren/try.sh index 4d9195141..b00006ee2 100755 --- a/2011/goren/try.sh +++ b/2011/goren/try.sh @@ -17,22 +17,26 @@ clear read -r -n 1 -p "Press any key to run: echo 'Hello, world!' | ./goren: " +echo 1>&2 echo "Hello, world!" | ./goren echo 1>&2 read -r -n 1 -p "Press any key to run: echo '|' | ./goren: " +echo 1>&2 echo '|' | ./goren echo 1>&2 read -r -n 1 -p "Press any key to run: echo '|!|!|' | ./goren: " +echo 1>&2 echo '|' | ./goren echo 1>&2 read -r -n 1 -p "Press any key to run: echo 'This is a pipe!' | ./goren: " +echo 1>&2 echo 'This is a pipe!' | ./goren echo 1>&2 read -r -n 1 -p "Press any key to run: echo '| is a pipe!' | ./goren: " +echo 1>&2 echo '| is a pipe!' | ./goren echo 1>&2 - diff --git a/thanks-for-help.md b/thanks-for-help.md index f2194b9bf..84930d28e 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3609,7 +3609,7 @@ and now it does work with 64-bit systems as well as 32-bit systems. Cody also added the [try.sh](/2011/goren/try.sh) script. -Cody added the following words of wisdom: '"this" is not a pipe but "!" is'. +Cody added the following words of wisdom: `'"this" is not a pipe but "!" is'`. ## [2011/hamaji](/2011/hamaji/hamaji.c) ([README.md](/2011/hamaji/README.md])) From 0e8139a5117b4923cb90d475560bcc00c5fec5b3 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:11:40 -0800 Subject: [PATCH 11/15] Improve 2011/hamaji/try.sh --- 2011/hamaji/try.sh | 53 +++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/2011/hamaji/try.sh b/2011/hamaji/try.sh index 0e19d08d4..b3c1cfff7 100755 --- a/2011/hamaji/try.sh +++ b/2011/hamaji/try.sh @@ -17,60 +17,65 @@ clear read -r -n 1 -p "Press any key to run: ./hamaji < dragon.nono (q = quit, space = next page): " echo 1>&2 -./hamaji < dragon.nono | less -X +./hamaji < dragon.nono | less -rEXF echo 1>&2 rm -f dragon dragon2 -echo "Checking if you have perl installed..." PERL="$(type -P perl)" -if [[ -n "$PERL" ]]; then +if [[ -n "$PERL" && -f "$PERL" && -x "$PERL" ]]; then echo "Perl installed, will generate output of ./hamaji < dragon.nono." - read -r -n 1 -p "Press any key to run: $PERL c2nono.pl hamaji.c | ./hamaji > dragon: " echo 1>&2 - "$PERL" c2nono.pl hamaji.c | ./hamaji > dragon - read -r -n 1 -p "Press any key to run: ./hamaji < dragon.nono > dragon2: " + echo "$ $PERL c2nono.pl hamaji.c | ./hamaji | tee dragon" + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + "$PERL" c2nono.pl hamaji.c | ./hamaji | tee dragon | less -rEXF echo 1>&2 - ./hamaji < dragon.nono > dragon2 + echo "$ ./hamaji < dragon.nono | tee dragon2" 1>&2 + read -r -n 1 -p "Press any key to run: ./hamaji < dragon.nono | tee dragon2 (space = next page, q = quit): " + echo 1>&2 + ./hamaji < dragon.nono | tee dragon2 | less -rEXF read -r -n 1 -p "Press any key to run: diff -s dragon dragon2: " echo 1>&2 diff -s dragon dragon2 +else + echo "Perl not found, will not run other steps." 1>&2 fi rm -f dragon dragon2 echo 1>&2 -read -r -n 1 -p "Press any key to run: ./hamaji < random.nono: " +read -r -n 1 -p "Press any key to run: ./hamaji < random.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < random.nono +./hamaji < random.nono | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to run: ./hamaji < soccer.nono: " +read -r -n 1 -p "Press any key to run: ./hamaji < soccer.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < soccer.nono +./hamaji < soccer.nono | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to run: ./hamaji < codegolf.nono: " +read -r -n 1 -p "Press any key to run: ./hamaji < codegolf.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < codegolf.nono +./hamaji < codegolf.nono | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to run: ./hamaji < face.nono: " +read -r -n 1 -p "Press any key to run: ./hamaji < face.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < face.nono +./hamaji < face.nono | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to run: ./hamaji < penguin.nono: " +read -r -n 1 -p "Press any key to run: ./hamaji < penguin.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < penguin.nono +./hamaji < penguin.nono | less -rEXF echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < samurai.nono (q = quit, space = next page): " echo 1>&2 -./hamaji < samurai.nono | less -X +./hamaji < samurai.nono | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to run: ./hamaji < conway-game-of-life.nono: " +echo "$ ./hamaji < conway-game-of-life.nono" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " echo 1>&2 -./hamaji < conway-game-of-life.nono +./hamaji < conway-game-of-life.nono | less -rEXF echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < no-solution.nono (no solution): " @@ -83,13 +88,13 @@ echo 1>&2 ./hamaji < multi-solutions.nono echo 1>&2 -read -r -n 1 -p "Press any key to run: ./hamaji < plus.nono: " +read -r -n 1 -p "Press any key to run: ./hamaji < plus.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < plus.nono +./hamaji < plus.nono | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to run: ./hamaji < smiley.nono: " +read -r -n 1 -p "Press any key to run: ./hamaji < smiley.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < smiley.nono +./hamaji < smiley.nono | less -rEXF exit 0 From 9c36a48fd134576264d6a6e88ba9b4fd550ce34c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:16:47 -0800 Subject: [PATCH 12/15] Improve 2011/hou/try.sh --- 2011/hou/try.sh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/2011/hou/try.sh b/2011/hou/try.sh index 6f7519e06..4cc3d65e8 100755 --- a/2011/hou/try.sh +++ b/2011/hou/try.sh @@ -15,32 +15,34 @@ 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 "Observe how this one is in the code, both the equation and the answer: " -echo "$ ./hou '11/26+222/31'" 1>&2 +echo "Observe how this one is in the code, both the equation and the answer: " 1>&2 +read -r -n 1 -p "Press any key to run: ./hou '11/26+222/31': " +echo 1>&2 ./hou '11/26+222/31' echo 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ ./hou 'log((21701-19937)-(23209-21701))/log(2)'" 1>&2 +read -r -n 1 -p "Press any key to run: ./hou 'log((21701-19937)-(23209-21701))/log(2)': " +echo 1>&2 ./hou 'log((21701-19937)-(23209-21701))/log(2)' echo 1>&2 -read -r -n 1 -p "Press any key to continue: " echo "$ ./hou 'sin(1.5708)+0.04321+log(sqrt(exp(1*1*1)))+(1+2*3)-0.4-0.6+(4+6)*(2-1+2*3)-tan(0.785398)+2*10/3*6*sqrt(16/2/2)*10+10000-1000'" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 ./hou 'sin(1.5708)+0.04321+log(sqrt(exp(1*1*1)))+(1+2*3)-0.4-0.6+(4+6)*(2-1+2*3)-tan(0.785398)+2*10/3*6*sqrt(16/2/2)*10+10000-1000' echo 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ ./hou '1+2*3'" 1>&2 +read -r -n 1 -p "Press any key to run: ./hou '1+2*3': " +echo 1>&2 ./hou '1+2*3' echo 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ ./hou '(1+2)*3'" 1>&2 +read -r -n 1 -p "Press any key to run: ./hou '(1+2)*3': " +echo 1>&2 ./hou '(1+2)*3' echo 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ ./hou 'a calculator expression -- see the C Code for details'" 1>&2 +read -r -n 1 -p "Press any key to run: ./hou 'a calculator expression -- see the C Code for details': " +echo 1>&2 ./hou 'a calculator expression -- see the C Code for details' echo "Now answer: what does the last one mean? Can you get it to report something else?" 1>&2 From 4cc95db8b01651a845b23b6918cfacfcc814675f Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:21:21 -0800 Subject: [PATCH 13/15] Improve 2011/konno/try.sh --- 2011/konno/try.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/2011/konno/try.sh b/2011/konno/try.sh index 077f38f53..6c64294af 100755 --- a/2011/konno/try.sh +++ b/2011/konno/try.sh @@ -16,18 +16,26 @@ make CC="$CC" all >/dev/null || exit 1 clear -echo "$ ./konno qwerty" 1>&2 +read -r -n 1 -p "Press any key to run: ./konno qwerty: " +echo 1>&2 ./konno qwerty echo 1>&2 -echo "$ ./konno ioccc" 1>&2 +read -r -n 1 -p "Press any key to run: ./konno ioccc: " +echo 1>&2 ./konno ioccc echo 1>&2 -echo "$ ./konno \"the quick brown fox jumps over the lazy dog\"" 1>&2 -./konno "the quick brown fox jumps over the lazy dog" +read -r -n 1 -p "Press any key to run: ./konno \"the quick brown fox jumps over the lazy dog\": " +echo 1>&2 +./konno 'the quick brown fox jumps over the lazy dog' echo 1>&2 -echo "$ ./konno \"\"" 1>&2 +read -r -n 1 -p "Press any key to run: ./konno \"\": " +echo 1>&2 ./konno "" +echo 1>&2 +read -r -n 1 -p "Press key to run: ./konno: " +echo 1>&2 +./konno From 3b0a3b12a06c413b6ac087e2f14d174811e87939 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:30:18 -0800 Subject: [PATCH 14/15] Add 2011/richards try scripts The bugs.md refers to the alt try script for testing any fix with the Apple silicon chip. If someone gets it to work the entry could be removed from the bugs.md file and the README.md file updated to refer to the alternate code. As the alternate code does not work (though it has a different type of crash) the alt build/try is not mentioned in the README.md file. It is not clear if it's helpful or not to have it in the README.md at this point as the important part is in bugs.md. --- 2011/richards/README.md | 3 +-- 2011/richards/try.alt.sh | 28 ++++++++++++++++++++++++++++ 2011/richards/try.sh | 28 ++++++++++++++++++++++++++++ bugs.md | 7 +++++++ thanks-for-help.md | 10 ++++++++-- 5 files changed, 72 insertions(+), 4 deletions(-) create mode 100755 2011/richards/try.alt.sh create mode 100755 2011/richards/try.sh diff --git a/2011/richards/README.md b/2011/richards/README.md index 3e3219423..287f0255b 100644 --- a/2011/richards/README.md +++ b/2011/richards/README.md @@ -4,7 +4,6 @@ make ``` - ### Bugs and (Mis)features: The current status of this entry is: @@ -19,7 +18,7 @@ For more detailed information see [2011 richards in bugs.md](/bugs.md#2011-richa ## To use: ```sh -./richards +./try.sh ``` diff --git a/2011/richards/try.alt.sh b/2011/richards/try.alt.sh new file mode 100755 index 000000000..0373e7d8c --- /dev/null +++ b/2011/richards/try.alt.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# +# try.alt.sh - demonstrate IOCCC winner 2011/richards alt code +# + +# 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 '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards.alt: " +echo 1>&2 +echo '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards.alt +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo '64 256 128 p/p*p' | ./richards.alt: " +echo 1>&2 +echo '64 256 128 p/p*p' | ./richards.alt +echo 1>&2 diff --git a/2011/richards/try.sh b/2011/richards/try.sh new file mode 100755 index 000000000..d0fcc13d6 --- /dev/null +++ b/2011/richards/try.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2011/richards +# + +# 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 '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards: " +echo 1>&2 +echo '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo '64 256 128 p/p*p' | ./richards: " +echo 1>&2 +echo '64 256 128 p/p*p' | ./richards +echo 1>&2 diff --git a/bugs.md b/bugs.md index bfd4cf016..907a7e70d 100644 --- a/bugs.md +++ b/bugs.md @@ -2868,6 +2868,13 @@ f *lib2[] = { T, ld, lp, lx, l1 } ; This can be fixed easily enough however but it doesn't appear to matter in this case. + +### Testing fixes + +It might be helpful to use the [try.alt.sh](/2011/richards/try.alt.sh) script to +test that it does not crash. + + ### Resources #### More from the author diff --git a/thanks-for-help.md b/thanks-for-help.md index 84930d28e..e8ad23df5 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3643,11 +3643,17 @@ Cody also added the [try.sh](/2011/konno/try.sh) script. however that as of this time this entry does not work properly with macOS at least with the silicon chip (Intel has not been tested) and it is quite possibly an inherent problem in macOS to do with executing code in in memory/JIT and in -particular with the silicon chip. See [bugs.md](/bugs.md) for more details and a +particular with the silicon chip. See [2011/richards in +bugs.md](/bugs.md#2011-richards) for more details and a document from Apple about how it might be fixed if anyone is brave enough to try. If they do they might want to look also at [richards.alt.c](/2011/richards/richards.alt.c), for whatever it might or might -not be worth. +not be worth, as it is a possible starting point that Cody added. + +Cody also added the [try.sh](/2011/richards/try.sh) and the +[try.alt.sh](/2011/richards/try.alt.sh) scripts. The `try.alt.sh` script will be +helpful to test any fixes for Apple silicon chips (see [2011/richards in +bugs.md](/bugs.md#2011-richards) for more details). ## [2011/toledo](/2011/toledo/toledo.c) ([README.md](/2011/toledo/README.md])) From 48e7331f57978af6379681be0d3a29246f49323c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:46:25 -0800 Subject: [PATCH 15/15] Add 2011/zucker/try.sh --- 2011/zucker/README.md | 8 +++++--- 2011/zucker/try.sh | 35 +++++++++++++++++++++++++++++++++++ thanks-for-help.md | 8 +++++--- 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100755 2011/zucker/try.sh diff --git a/2011/zucker/README.md b/2011/zucker/README.md index 7c160afb9..2a1e1ed11 100644 --- a/2011/zucker/README.md +++ b/2011/zucker/README.md @@ -14,15 +14,17 @@ binary mode from text mode. See [alternate code](#alternate-code) below. ./zucker > image.ppm ``` +Now open `image.ppm` with your image viewer of choice. + ## Try: ```sh -./zucker "Hello\!\!\!" > hello.ppm -./zucker faster\! -preview > image2.ppm +./try.sh ``` -Display the PPM image with your favorite image viewer. +After running `try.sh`, open the PPM images `ioccc.ppm`, `hello.ppm` and +`image2.ppm` with your image viewer of choice. ## Alternate code: diff --git a/2011/zucker/try.sh b/2011/zucker/try.sh new file mode 100755 index 000000000..df0444eb2 --- /dev/null +++ b/2011/zucker/try.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2011/zucker +# + +# 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 + +# in this case we won't fail if we can't compile the code because we can still +# run the supplementary program. +make CC="$CC" all >/dev/null + +# clear screen after compilation so that only the entry is shown +clear + + +read -r -n 1 -p "Press any key to run: ./zucker > ioccc.ppm: " +echo 1>&2 +./zucker > ioccc.ppm +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./zucker \"Hello!!!\" > hello.ppm: " +echo 1>&2 +./zucker "Hello\!\!\!" > hello.ppm + +read -r -n 1 -p "Press any key to run: ./zucker faster\! -preview > image2.ppm: " +echo 1>&2 +./zucker faster\! -preview > image2.ppm +echo 1>&2 + + diff --git a/thanks-for-help.md b/thanks-for-help.md index e8ad23df5..c7f603d72 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3676,13 +3676,15 @@ header files). To build try the alt rule of the Makefile. ## [2011/zucker](/2011/zucker/zucker.c) ([README.md](/2011/zucker/README.md])) -[Cody](#cody) added [alt code](/2011/zucker/README.md#alternate-code) that should work on +[Cody](#cody) added the [try.sh](/2011/zucker/try.sh) script. + +Cody also added [alt code](/2011/zucker/README.md#alternate-code) that should work on Windows, based on the author's remarks that if the system distinguishes binary and text then `stdout` needs to be set to binary mode. Cody also added the PDF file -[sphere-tracing.pdf](/2011/zucker/sphere-tracing.pdf) in case the link eventually -dies. +[sphere-tracing.pdf](/2011/zucker/sphere-tracing.pdf) in case the link +eventually dies. # 2012