diff --git a/2013/birken/README.md b/2013/birken/README.md index 44d2531b5..b7f89f8e0 100644 --- a/2013/birken/README.md +++ b/2013/birken/README.md @@ -26,7 +26,7 @@ the value used in `usleep(3)`. The default is `-DZ=13500`. To see the program run on each text file, try: ```sh -./try.sh +./try.alt.sh ``` If you have perl installed it will also try a random run. @@ -81,7 +81,7 @@ Use `birken` as you would `birken.alt` above. To use the demo script with the original code, try: ```sh -BIRKEN=birken ./try.sh +./try.sh ``` PLEASE be careful if you are sensitive to flashing colours! diff --git a/2013/birken/try.alt.sh b/2013/birken/try.alt.sh new file mode 100755 index 000000000..32604bcb4 --- /dev/null +++ b/2013/birken/try.alt.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2013/birken 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 clobber CC="$CC" everything >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + + +trap 'reset; exit' 0 1 2 3 15 + +PERL="$(type -P perl)" + +if [[ -n "$PERL" ]]; then + read -r -n 1 -p "Press any key to try a random run: " + perl -e 'map{map{print int(rand()*8);}(0..16);print chr(10);}(0..30);' | tr '[0-4]' ' '| ./birken.alt +fi + +for i in *.txt; do + NAME="$(echo "$i" | awk '{ print toupper(substr($1,1,1)) substr($1,2)}'|sed -e 's/\.txt//g' \ + -e 's/Ioccc/IOCCC/g' -e 's/Mspacman/Ms Pac-Man/g' -e 's/Helloworld/Hello World/g' \ + -e 's/Cheepcheep/Cheep Cheep/g' -e 's/Happyface/Happy Face/g' -e 's/Paranaplant/Piranha Plant/g' \ + -e 's/Koopaparatroopa/Koopa Paratroopa/g')" + read -r -n1 -p "Press any key to try $NAME: " + ./birken.alt < "$i" + echo +done +clear diff --git a/2013/birken/try.sh b/2013/birken/try.sh index 8c6f925b2..f08c8e1e4 100755 --- a/2013/birken/try.sh +++ b/2013/birken/try.sh @@ -14,17 +14,13 @@ make clobber CC="$CC" everything >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -if [[ -z "$BIRKEN" ]]; then - BIRKEN="birken.alt" -fi - trap 'reset; exit' 0 1 2 3 15 PERL="$(type -P perl)" if [[ -n "$PERL" ]]; then read -r -n 1 -p "Press any key to try a random run: " - perl -e 'map{map{print int(rand()*8);}(0..16);print chr(10);}(0..30);' | tr '[0-4]' ' '| ./birken.alt + perl -e 'map{map{print int(rand()*8);}(0..16);print chr(10);}(0..30);' | tr '[0-4]' ' '| ./birken fi for i in *.txt; do @@ -33,7 +29,7 @@ for i in *.txt; do -e 's/Cheepcheep/Cheep Cheep/g' -e 's/Happyface/Happy Face/g' -e 's/Paranaplant/Piranha Plant/g' \ -e 's/Koopaparatroopa/Koopa Paratroopa/g')" read -r -n1 -p "Press any key to try $NAME: " - ./"${BIRKEN}" < "$i" + ./birken < "$i" echo done clear diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 07772221d..a1666e3d6 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3481,11 +3481,12 @@ the same) so that as long as it runs to completion the terminal will be sane and the cursor will be visible. Using `atexit(3)` will not work if the program is killed and signals are ugly so this was not done. -Cody also added the [try.sh](2013/birken/try.sh) script and the alternate -version (that has the above fix) which allows one to control how fast the -painting is done, based on the author's recommendations, except that Cody made -it configurable at compile time just like he did with other entries that use -`usleep(3)`. +Cody also added the alt version that lets one control how fast the painting is +done, based on the author's recommendations, except that Cody made it +configurable at compile time. + +Cody also added the [try.sh](2013/birken/try.sh) script for the entry and the +[try.alt.sh](2013/birken/try.alt.sh) script for the alt code. ## [2013/cable3](2013/cable3/cable3.c) ([README.md](2013/cable3/README.md]))