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 } diff --git a/1996/gandalf/try.sh b/1996/gandalf/try.sh index b205fca90..4acf4097a 100755 --- a/1996/gandalf/try.sh +++ b/1996/gandalf/try.sh @@ -18,6 +18,22 @@ 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 "Oh well, never mind that, moving on ..." 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 @@ -25,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 } @@ -56,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 @@ -67,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 @@ -78,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 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 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 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 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 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 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/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 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 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 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/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/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 f2194b9bf..c7f603d72 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])) @@ -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])) @@ -3670,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