From 3fdcf5cb2c670f3ed736bb21ba9ef6622b425f2d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 09:09:48 -0800 Subject: [PATCH 1/9] Improve 2005/aidan try scripts --- 2005/aidan/try.alt.sh | 31 +++++++++++++++---------------- 2005/aidan/try.sh | 40 ++++++++++++++++++++++------------------ thanks-for-help.md | 15 ++++++++------- 3 files changed, 45 insertions(+), 41 deletions(-) diff --git a/2005/aidan/try.alt.sh b/2005/aidan/try.alt.sh index 2fd1e79d0..8867fe4a8 100755 --- a/2005/aidan/try.alt.sh +++ b/2005/aidan/try.alt.sh @@ -21,27 +21,26 @@ echo "When looking at the output, notice how some of the output is different" 1> echo "from the aidan.c." 1>&2 echo 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ ./$AIDAN < blank.sudoku" 1>&2 -./"$AIDAN" < blank.sudoku +read -r -n 1 -p "Press any key to run: ./$AIDAN < blank.sudoku (space = next page, q = quit): " +echo 1>&2 +./"$AIDAN" < blank.sudoku | less -rEXF echo 1>&2 -read -r -n 1 -p "Press any key to continue: " - - -echo "$ echo IOCCC | ./$AIDAN" 1>&2 -echo IOCCC | ./"$AIDAN" +read -r -n 1 -p "Press any key to run: echo IOCCC | ./$AIDAN (space = next page, q = quit): " +echo IOCCC | ./"$AIDAN" | less -rEXF echo "What just happened?" 1>&2 echo 1>&2 -echo "$ echo IOCCC | ./$AIDAN 42" 1>&2 -read -r -n 1 -p "Press any key to continue (q = exit pager space = go down a page): " -echo IOCCC | ./"$AIDAN" 42 1>&2 +read -r -n 1 -p "Press any key to run: echo IOCCC | ./$AIDAN 42 (space = next page, q = quit): " +echo IOCCC | ./"$AIDAN" 42 1>&2 | less -rEXF +echo 1>&2 echo "Seeing that, was the 'echo IOCCC' relevant?" 1>&2 echo 1>&2 - -echo "$ ./$AIDAN < insane1.sudoku" 1>&2 -read -r -n 1 -p "Press any key to continue: " -./"$AIDAN" < insane1.sudoku -echo "Did you notice how much slower this is than aidan? If not try try.sh!" 1>&2 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./$AIDAN < insane1.sudoku (space = next page, q = quit): " +echo 1>&2 +./"$AIDAN" < insane1.sudoku +echo 1>&2 +echo "Did you notice how much slower this is than aidan.c? If not try try.sh!" 1>&2 echo 1>&2 diff --git a/2005/aidan/try.sh b/2005/aidan/try.sh index 6c930e728..098a96e19 100755 --- a/2005/aidan/try.sh +++ b/2005/aidan/try.sh @@ -18,37 +18,41 @@ clear AIDAN="aidan" echo "$ ./$AIDAN < blank.sudoku" 1>&2 -./"$AIDAN" < blank.sudoku +read -r -n 1 -p "Press any key to run: ./$AIDAN < blank.sudoku (space = next page, q = quit): " +echo 1>&2 +./"$AIDAN" < blank.sudoku | less -rEXF echo 1>&2 -echo "$ ./$AIDAN U < blank.sudoku" 1>&2 -read -r -n 1 -p "Press any key to continue: " -./"$AIDAN" U < blank.sudoku +read -r -n 1 -p "Press any key to run: ./$AIDAN U < blank.sudoku (space = next page, q = quit): " +echo 1>&2 +./"$AIDAN" U < blank.sudoku | less -rEXF +echo 1>&2 echo "What was the difference between the previous command?" 1>&2 echo "More specifically, what did it do?" 1>&2 echo 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ echo IOCCC | ./$AIDAN" 1>&2 -echo IOCCC | ./"$AIDAN" +read -r -n 1 -p "Press any key to run: echo IOCCC | ./$AIDAN (space = next page, q = quit): " +echo 1>&2 +echo IOCCC | ./"$AIDAN" | less -rEXF +echo 1>&2 echo "What just happened?" 1>&2 echo 1>&2 - echo 1>&2 -echo "$ echo IOCCC | ./$AIDAN 42 | less -r" 1>&2 -read -r -n 1 -p "Press any key to continue (q = exit pager space = go down a page): " -echo IOCCC | ./"$AIDAN" 42 | less -r + +read -r -n 1 -p "Press any key to run: echo IOCCC | ./$AIDAN 42 (space = next page, q = quit): " +echo 1>&2 +echo IOCCC | ./"$AIDAN" 42 | less -rEXF +echo 1>&2 echo "Seeing that, was the 'echo IOCCC' relevant?" 1>&2 echo 1>&2 -echo "$ ./$AIDAN < insane1.sudoku" 1>&2 -read -r -n 1 -p "Press any key to continue: " -./"$AIDAN" < insane1.sudoku +read -r -n 1 -p "Press any key to run: ./$AIDAN < insane1.sudoku (space = next page, q = quit): " +./"$AIDAN" < insane1.sudoku | less -rEXF read -r -n 1 -p "Do you with to run the test suite (y/n)? " -if [[ "$REPLY" = "y" ]]; then +if [[ "$REPLY" = "y" || "$REPLY" = "Y" ]]; then echo 1>&2 - echo "$ make test" 1>&2 - read -r -n 1 -p "Press any key to continue: " - 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 -rEXF fi diff --git a/thanks-for-help.md b/thanks-for-help.md index bbcfeba61..b3ef61296 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3161,16 +3161,17 @@ just to make it a bit easier to compile. ## [2005/aidan](/2005/aidan/aidan.c) ([README.md](/2005/aidan/README.md])) [Cody](#cody) fixed the test script, described by the author in their remarks, to refer -to the proper compiled program (it's hardcoded). This had never been done and it -broke the script. +to the proper compiled program (it's hardcoded). This had never been done and so +the script did not even work (at least modernly?). He also added the [alt code](/2005/aidan/README.md#alternate-code) based on the -author's remarks which is a different approach than the one used and which 'is -slower (particularly in worst-case or nearly so scenarios), inelegant, and not a -good starting place for sudoku generation.' +author's remarks which is a different approach than the one used and which +(according to the author) 'is slower (particularly in worst-case or nearly so +scenarios), inelegant, and not a good starting place for sudoku generation.' -The [try.sh](/2005/aidan/try.sh) and [try.alt.sh](/2005/aidan/try.alt.sh) -correspond to the entry and alt code respectively. +Cody added the [try.sh](/2005/aidan/try.sh) and +[try.alt.sh](/2005/aidan/try.alt.sh) scripts that correspond to the entry and +alt code respectively. Cody added the `make test` and `make test-n0` rules for easier use of the test suite. From d5dd94d85ac84eb553ba89866faf0c4a59dd355a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 09:11:44 -0800 Subject: [PATCH 2/9] Minor adjustments in 2005/anon/README.md --- 2005/anon/README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/2005/anon/README.md b/2005/anon/README.md index 75f42774a..a4f886da9 100644 --- a/2005/anon/README.md +++ b/2005/anon/README.md @@ -37,6 +37,7 @@ For more detailed information see [2005 anon in bugs.md](/bugs.md#2005-anon). ```sh ./anon 4 4 + ./anon 3 3 3 ``` @@ -45,13 +46,6 @@ to destroy its runtime stack. This is the author's way to prevent you from being frustrated (which might happen as it likes to create unsolvable puzzles just to hook you) and spending too much time playing. :-) -This is supposed to happen. As is written in the -[The Jargon File](http://catb.org/jargon/html/F/feature.html): - -``` -That's not a bug, that's a feature. -``` - If you want to see this in action you can easily do this: ```sh From 4f089535b6431e21c940e4b702f8496f66b85789 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 09:30:53 -0800 Subject: [PATCH 3/9] Add 2005/boutines/try.sh --- 2005/boutines/README.md | 25 ++++++++------- 2005/boutines/try.sh | 69 +++++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 2 ++ 3 files changed, 84 insertions(+), 12 deletions(-) create mode 100755 2005/boutines/try.sh diff --git a/2005/boutines/README.md b/2005/boutines/README.md index 617a11435..d013543a6 100644 --- a/2005/boutines/README.md +++ b/2005/boutines/README.md @@ -7,37 +7,38 @@ make ## To use: -You will need an [SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) viewer. +You will need an [SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) viewer or +a converter like [ImageMagick](https://imagemagick.org/index.php)'s `convert`. + Look here to find some [SVG Viewer Implementations](https://www.w3.org/Graphics/SVG/WG/wiki/Implementations). -The following will create an `SVG` file: - ```sh -ruby -e '20.times{puts "#{rand} #{rand}"}' | ./boutines > test.svg +./boutines < input > output.svg ``` ## Try: ```sh -./boutines < input.txt > result.svg +./try.sh ``` -After running the above commands, use [ImageMagick](https://imagemagick.org/index.php)'s -`convert` tool to convert the images to a png file: +If `ruby` is installed [try.sh](try.sh) will generate an SVG file by: ```sh -convert test.svg test.png - -convert result.svg result.png +ruby -e '20.times{puts "#{rand} #{rand}"}' | ./boutines > test.svg ``` -and then open it with your preferred graphics viewer or editor. +It will also create an SVG file with the file [input.txt](input.txt). + +The script will check if `convert` is available and if so it will try converting +the SVG file(s) to PNG file(s) which you should be able to view in most any +graphics viewer, editor or web browser. If you have a program that opens [SVG](https://www.w3.org/TR/SVG11/expanded-toc.html) files then you could open -the `test.svg` file directly. An example program is +the `test.svg` and `result.svg` files directly. An example program is [Inkscape](https://inkscape.org). See the [list](https://www.w3.org/Graphics/SVG/WG/wiki/Implementations) cited above for others. diff --git a/2005/boutines/try.sh b/2005/boutines/try.sh new file mode 100755 index 000000000..aae39ffbf --- /dev/null +++ b/2005/boutines/try.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2005/boutines +# + +# 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 + +# see if the user has ruby installed +# +RUBY="$(type -P ruby)" + +# see if convert(1) is available (hopefully from ImageMagick :-) ) +# +CONVERT="$(type -P convert)" + +if [[ -n "$RUBY" ]]; then + echo "$ $RUBY -e '20.times{puts \"\#{rand} \#{rand}\"}' | ./boutines > test.svg" 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + "$RUBY" -e '20.times{puts "#{rand} #{rand}"}' | ./boutines > test.svg +else + echo "ruby not installed, skipping generation of an SVG file via ruby." 1>&2 +fi + +read -r -n 1 -p "Press any key to run: ./boutines < input.txt > result.svg: " +echo 1>&2 +./boutines < input.txt > result.svg +echo 1>&2 + +if [[ ! -f result.svg && ! -f test.svg ]]; then + echo "failed to create any SVG file, exiting." 1>&2 + exit 1 +fi + +if [[ -n "$CONVERT" ]]; then + + read -r -n 1 -p "Press any key to run: convert test.svg test.png: " + echo 1>&2 + if ! convert test.svg test.png; then + echo "Failed to convert test.svg to test.png, try a graphics viewer that" 1>&2 + echo "can view SVG files." 1>&2 + else + echo "Now try viewing test.png with your favourite graphics viewer." 1>&2 + fi + + echo 1>&2 + read -r -n 1 -p "Press any key to run: convert result.svg result.png: " + echo 1>&2 + if ! convert result.svg result.png; then + echo "Failed to convert result.svg to result.png, try a graphics viewer that" 1>&2 + echo "can view SVG files." 1>&2 + else + echo "Now try viewing result.png with your favourite graphics viewer." 1>&2 + fi +else + echo 1>&2 + echo "convert not found (ImageMagick not installed?)" 1>&2 + echo "Try viewing *.svg with a graphics viewer that can view SVG files." 1>&2 +fi diff --git a/thanks-for-help.md b/thanks-for-help.md index b3ef61296..1a3a499f3 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3196,6 +3196,8 @@ movements. [Cody](#cody) added the [input.txt](/2005/boutines/input.txt) data file based on suggested input from the author, adapting it to a command to try out. +Cody also added the [try.sh](/2005/boutines/try.sh) script. + ## [2005/giljade](/2005/giljade/giljade.c) ([README.md](/2005/giljade/README.md])) From f72856c5198166a0788760cee97d1e63c37861c0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 09:45:34 -0800 Subject: [PATCH 4/9] Improve scripts for 2005/giljade Prompt to run test suite after the main feature is done and improve the prompting. The test suite script gives a warning that it may take a bit of time to run. --- 2005/giljade/test.sh | 3 +++ 2005/giljade/try.sh | 26 ++++++++++++++++---------- thanks-for-help.md | 6 +++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/2005/giljade/test.sh b/2005/giljade/test.sh index 8c3c636e3..419dcc3a3 100755 --- a/2005/giljade/test.sh +++ b/2005/giljade/test.sh @@ -24,6 +24,9 @@ EXIT_CODE=0 # delete temporary files first to make sure that they're clean rm -f out out.count +echo "This may take a while: please be patient." 1>&2 +echo 1>&2 + # redirect stdout to 'out' so that we can run the test suite of giljade ./"$GILJADE" > out # here we want to show only the lines matching the regexp '^Line' but write diff --git a/2005/giljade/try.sh b/2005/giljade/try.sh index 866edb149..449747284 100755 --- a/2005/giljade/try.sh +++ b/2005/giljade/try.sh @@ -15,21 +15,27 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -read -r -p "Do you wish to run the test suite (y/n) ? " -if [[ "$REPLY" == "y" ]]; then - echo "$ make test" 1>&2 - make test -fi - +# We don't use tee(1) here so as to show better what we're doing and to prompt +# them to view the file with less(1) rather than dump it on them all at once. +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./giljade > out: " echo 1>&2 -echo "$ ./giljade > out" 1>&2 ./giljade > out +echo 1>&2 echo "For this next step, make sure to keep pressing space (or hold it down) (q = quit)." 1>&2 -echo "$ less -X out" 1>&2 -read -r -n 1 -p "Press any key to continue: " -less -X out +read -r -n 1 -p "Press any key to run: less -rEXF out: " +less -rEXF out echo 1>&2 echo "We've left the file 'out' for you in case you wish to open it in vi(m). If" 1>&2 echo "you do we recommend you try holding ctrl-f down in a similar way to how you held" 1>&2 echo "down space above. Of course you can open it in another editor if you wish." 1>&2 +echo 1>&2 + +read -r -p "Do you wish to run the test suite (y/n) ? " +if [[ "$REPLY" == "y" || "$REPLY" = "Y" ]]; then + echo "$ make test" 1>&2 + make test +fi + + diff --git a/thanks-for-help.md b/thanks-for-help.md index 1a3a499f3..d3d5580a6 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3201,9 +3201,9 @@ Cody also added the [try.sh](/2005/boutines/try.sh) script. ## [2005/giljade](/2005/giljade/giljade.c) ([README.md](/2005/giljade/README.md])) -After Landon fixed the entry to compile with clang Cody noticed this does not -work at all in modern systems (see below). He fixed this to work and then he -later fixed the self-test feature. +After Landon fixed the entry to compile with clang [Cody](#cody) noticed this +does not work at all in modern systems (see below). He fixed this to work and +then he later fixed the self-test feature. The problem that was showing up is that with either optimising or if anything but 32-bit (as in `-m32`) was used it would not work (at least in 64-bit From eec94200e832424189137b16cb0558d013befbac Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 09:55:54 -0800 Subject: [PATCH 5/9] Improve and typo fix 2005/klausler/try.sh Fun fact: the Lion king is an anagram for 'thinking Leo'. And what is Leo? The Lion constellation! :-) --- 2005/klausler/try.sh | 51 +++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/2005/klausler/try.sh b/2005/klausler/try.sh index 393143297..31991126a 100755 --- a/2005/klausler/try.sh +++ b/2005/klausler/try.sh @@ -15,35 +15,62 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ ./klausler peter klausler | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler peter klausler | head -n 10: " +echo 1>&2 ./klausler peter klausler | head -n 10 +echo 1>&2 -echo "$ ./klausler abc def ghi jkl mno | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler abc def ghi jkl mno | head -n 10: " +echo 1>&2 ./klausler abc def ghi jkl mno | head -n 10 +echo 1>&2 -echo "$ ./klausler foo bar baz | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler foo bar baz | head -n 10: " +echo 1>&2 ./klausler foo bar baz | head -n 10 +echo 1>&2 -echo "$ ./klausler zebra elephant bear fox | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler zebra elephant bear fox | head -n 10: " +echo 1>&2 ./klausler zebra elephant bear fox | head -n 10 +echo 1>&2 -echo "$ ./klausler the lion king | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler the lion king | head -n 10: " +echo 1>&2 ./klausler the lion king | head -n 10 +echo 1>&2 -echo "$ ./klausler fire breathing dragon | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler fire breathing dragon | head -n 10: " +echo 1>&2 ./klausler fire breathing dragon | head -n 10 +echo 1>&2 -echo "$ ./klausler lord of the rings | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler lord of the rings | head -n 10: " +echo 1>&2 ./klausler lord of the rings | head -n 10 +echo 1>&2 -echo "$ ./klausler fawlty towers | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler fawlty towers | head -n 10: " +echo 1>&2 ./klausler fawlty towers | head -n 10 +echo 1>&2 -echo "$ ./klausler carriown fowl | head -n 10" 1>&2 -./klausler carriown fowl | head -n 10 +read -r -n 1 -p "Press any key to run: ./klausler carrion fowl | head -n 10: " +echo 1>&2 +./klausler carrion fowl | head -n 10 +echo 1>&2 -echo "$ ./klausler werewolf vampire dragon | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler werewolf vampire dragon | head -n 10: " +echo 1>&2 ./klausler werewolf vampire dragon | head -n 10 +echo 1>&2 -echo "$ ./klausler werewolf vampire | head -n 10" 1>&2 +read -r -n 1 -p "Press any key to run: ./klausler werewolf vampire elf dragon | head -n 10: " +echo 1>&2 +./klausler werewolf vampire elf dragon | head -n 10 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./klausler werewolf vampire | head -n 10: " +echo 1>&2 ./klausler werewolf vampire | head -n 10 +echo 1>&2 From 3b1696c346cd9f5758c34d9199001d5a46e34bb0 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 11:16:33 -0800 Subject: [PATCH 6/9] Improve/fix 2005/mikeash/try.sh --- 2005/mikeash/try.sh | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/2005/mikeash/try.sh b/2005/mikeash/try.sh index 3d5f1c5d4..11488cc55 100755 --- a/2005/mikeash/try.sh +++ b/2005/mikeash/try.sh @@ -16,27 +16,44 @@ make CC="$CC" all >/dev/null || exit 1 clear -echo "$ ./mikeash < mikeash.c" 1>&2 +read -r -n 1 -p "Press any key to run: ./mikeash < mikeash.c (space = next page, q = quit): " +echo 1>&2 ./mikeash < mikeash.c +echo 1>&2 echo 1>&2 echo "The next command should print nothing." 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ ./mikeash < mikeash.c | diff - mikeash.c" 1>&2 -./mikeash < mikeash.c | diff - mikeash.c - +read -r -n 1 -p "Press any key to run: ./mikeash < mikeash.c | diff - mikeash.c: " echo 1>&2 +# ShellCheck is incorrect here: +# +# SC2094 (info): Make sure not to read and write the same file in the same pipeline. +# +# so we disable it. +# +# shellcheck disable=SC2094 +./mikeash < mikeash.c | diff - mikeash.c +echo 1>&2 + echo "For the next two commands we will add a newline after the command's output" 1>&2 echo "for your convenience as they will not print a newline themselves." 1>&2 echo 1>&2 echo "The next command should show: \"4." 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ echo '(format t "~s" (+ 2 2 ))' | ./mikeash" 1>&2 +read -r -n 1 -p "Press any key to run: echo '(format t \"~s\" (+ 2 2 ))' | ./mikeash: " +echo 1>&2 echo '(format t "~s" (+ 2 2 ))' | ./mikeash echo 1>&2 echo "The next command will evaluate the expression: (2+2) * (5 - 9/3), giving 8\"." 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo "$ echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash" 1>&2 + +# ShellCheck warns: +# +# SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? +# +# ShellCheck is wrong. +# +# shellcheck disable=SC2140 +read -r -n 1 -p "Press any key to run: echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash: " +echo 1>&2 echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash echo 1>&2 From c7620f2b96780c37b4327917dbcf47fbc4a09974 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 11:24:51 -0800 Subject: [PATCH 7/9] Add 2005/persano/try.sh --- 2005/persano/.gitignore | 1 + 2005/persano/README.md | 4 ++-- 2005/persano/try.sh | 45 +++++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 2 ++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100755 2005/persano/try.sh diff --git a/2005/persano/.gitignore b/2005/persano/.gitignore index b47eaf316..679625f01 100644 --- a/2005/persano/.gitignore +++ b/2005/persano/.gitignore @@ -8,3 +8,4 @@ indent.o persano persano.orig prog.orig +seal.gif diff --git a/2005/persano/README.md b/2005/persano/README.md index 5f7a3390f..44e755e5a 100644 --- a/2005/persano/README.md +++ b/2005/persano/README.md @@ -18,10 +18,10 @@ setting binary mode on `stdout`. See [alternate code](#alternate-code) below. ## Try: ```sh -./persano 3 16 > knot3-16.gif +./try.sh ``` -Open the [GIF](https://en.wikipedia.org/wiki/GIF) file with a viewer capable of +Open the [GIF](https://en.wikipedia.org/wiki/GIF) files with a viewer capable of displaying animated GIFs and watch closely at the bottom of the picture (you may need to use [gifsicle](https://www.lcdf.org/gifsicle/) - a great tool to manipulate animated GIFs - to slow down the animation and to compress the GIFs diff --git a/2005/persano/try.sh b/2005/persano/try.sh new file mode 100755 index 000000000..f9a45f5ec --- /dev/null +++ b/2005/persano/try.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2005/persano +# + +# 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: ./persano 3 16 > knot3-16.gif: " +echo 1>&2 +./persano 3 16 > knot3-16.gif +echo 1>&2 +if [[ -f knot3-16.gif ]]; then + echo "Now open the file knot3-16.gif in a GIF viewer capable of viewing animated" 1>&2 + echo "GIFs. See the README.md for details on a tool to manipulate it, if you wish." 1>&2 +fi + +read -r -n 1 -p "Press any key to run: ./persano 3 2 1 > foo.gif: " +echo 1>&2 +./persano 3 2 1 > foo.gif +echo 1>&2 +if [[ -f foo.gif ]]; then + echo "Now open the file foo.gif in a GIF viewer capable of viewing animated" 1>&2 + echo "GIFs. See the README.md for details on a tool to manipulate it, if you wish." 1>&2 +fi + +read -r -n 1 -p "Press any key to run: ./persano 5 2 > seal.gif: " +echo 1>&2 +./persano 5 2 > seal.gif +echo 1>&2 + +if [[ -f seal.gif ]]; then + echo "Now open seal.gif (Solomon's Seal knot) in a GIF viewer capable of viewing" 1>&2 + echo "animated GIFs. See the README.md for details on a tool to manipulate it, if you wish." 1>&2 +fi diff --git a/thanks-for-help.md b/thanks-for-help.md index d3d5580a6..ce80553d1 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3330,6 +3330,8 @@ code](/2005/persano/README.md#alternate-code) which should work for Windows as i sets binary mode on `stdout`. It is untested as Cody has no Windows system to test it on. +Cody also added the [try.sh](/2005/persano/try.sh) script. + ## [2005/sykes](/2005/sykes/sykes.c) ([README.md](/2005/sykes/README.md])) From b65d58627d48cc7625fc7a49100232b88f2badeb Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 11:27:07 -0800 Subject: [PATCH 8/9] Improve 2005/timwi/try.sh --- 2005/timwi/try.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/2005/timwi/try.sh b/2005/timwi/try.sh index 424826695..6a80c397a 100755 --- a/2005/timwi/try.sh +++ b/2005/timwi/try.sh @@ -21,6 +21,8 @@ clear echo "$ (echo \"20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; \ echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]\") | ./timwi" 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 (echo "20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]") | ./timwi echo 1>&2 echo "Now please go take better care of your brain. You only get one." 1>&2 From d619925ebadcbff8bc1149b9b88a77763f6c0919 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sun, 21 Jan 2024 11:30:52 -0800 Subject: [PATCH 9/9] Improve 2006/birken/try.sh --- 2006/birken/try.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/2006/birken/try.sh b/2006/birken/try.sh index f1b0e856b..7054b14e7 100755 --- a/2006/birken/try.sh +++ b/2006/birken/try.sh @@ -16,53 +16,66 @@ make CC="$CC" all >/dev/null || exit 1 clear read -r -n 1 -p "Press any key to run: ./birken < adder.tofu 2>/dev/null: " +echo 1>&2 ./birken < adder.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < buffer.tofu 2>/dev/null: " +echo 1>&2 ./birken < buffer.tofu 2>/dev/null echo 1>&2 -echo "NOTE: the next one has longer output." 1>&2 -read -r -n 1 -p "Press any key to run: ./birken < computer.tofu 2>/dev/null: " -./birken < computer.tofu 2>/dev/null +read -r -n 1 -p "Press any key to run: ./birken < computer.tofu 2>/dev/null (space = next page, q = quit): " +echo 1>&2 +./birken < computer.tofu 2>/dev/null | less -rEXF echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < counter.tofu 2>/dev/null: " +echo 1>&2 ./birken < counter.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < divider.tofu 2>/dev/null: " +echo 1>&2 ./birken < divider.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < lfsr.tofu 2>/dev/null: " +echo 1>&2 ./birken < lfsr.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < memory.tofu 2>/dev/null: " +echo 1>&2 ./birken < memory.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < multiplier.tofu 2>/dev/null: " +echo 1>&2 ./birken < multiplier.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < multiplier2.tofu 2>/dev/null: " +echo 1>&2 ./birken < multiplier2.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < oneline.tofu 2>/dev/null: " +echo 1>&2 ./birken < oneline.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < shift.tofu 2>/dev/null: " +echo 1>&2 ./birken < shift.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < zuse.tofu 2>/dev/null: " +echo 1>&2 ./birken < zuse.tofu 2>/dev/null echo 1>&2 read -r -n 1 -p "Press any key to run: ./birken < zuse2.tofu 2>/dev/null: " +echo 1>&2 ./birken < zuse2.tofu 2>/dev/null +echo 1>&2