diff --git a/1992/gson/try.sh b/1992/gson/try.sh index 5e9112572..8a4fe43ef 100755 --- a/1992/gson/try.sh +++ b/1992/gson/try.sh @@ -33,43 +33,30 @@ if [[ -z "$DICT" || ! -f "$DICT" || ! -r "$DICT" ]]; then fi fi +ag() +{ + if [[ "$#" -lt 2 ]]; then + echo "$0: ag() requires at least two args, given: $#" 1>&2 + return + fi + + echo "$ ./ag ${@:2} < $1" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + echo 1>&2 + ./ag "${@:2}" < "$1" 2>/dev/null | less -rEXF + + echo 1>&2 +} # safety check that DICT is not empty and is a readable file # if [[ -n "$DICT" && -f "$DICT" && -r "$DICT" ]]; then - echo "$ ./ag free software foundation < $DICT" 1>&2 - read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " - echo 1>&2 - ./ag free software foundation < "$DICT" 2>/dev/null | less -rEXF - - echo "$ ./ag obfuscated c contest < $DICT" 1>&2 - read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " - echo 1>&2 - ./ag obfuscated c contest < "$DICT" 2>/dev/null | less -rEXF - - echo "$ ./ag unix international < $DICT" 1>&2 - read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " - echo 1>&2 - ./ag unix international < "$DICT" 2>/dev/null | less -rEXF - - echo "$ ./ag george bush < $DICT" 1>&2 - read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " - echo 1>&2 - ./ag george bush < "$DICT" 2>/dev/null | less -rEXF - - echo "$ ./ag bill clinton < $DICT" 1>&2 - read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " - echo 1>&2 - ./ag bill clinton < "$DICT" 2>/dev/null | less -rEXF - - echo "$ ./ag ross perot < $DICT" 1>&2 - read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " - echo 1>&2 - ./ag ross perot < "$DICT" 2>/dev/null | less -rEXF - - echo "$ ./ag paul e tsongas < $DICT" 1>&2 - read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " - echo 1>&2 - ./ag paul e tsongas < "$DICT" 2>/dev/null | less -rEXF + ag "$DICT" free software foundation + ag "$DICT" obfuscated c contest + ag "$DICT" unix international + ag "$DICT" george bush + ag "$DICT" bill clinton + ag "$DICT" ross perot + ag "$DICT" paul e tsongas fi # now try making our own dictionary with mkdict.sh: @@ -80,38 +67,11 @@ DICT="words" read -r -n 1 -p "Press any key to use our own dict from mkdict.sh: " echo 1>&2 +ag "$DICT" free software foundation +ag "$DICT" obfuscated c contest +ag "$DICT" unix international +ag "$DICT" george bush +ag "$DICT" bill clinton +ag "$DICT" ross perot +ag "$DICT" paul e tsongas -echo "$ ./ag free software foundation < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag free software foundation < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag obfuscated c contest < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag obfuscated c contest < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag unix international < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag unix international < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag george bush < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag george bush < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag bill clinton < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag bill clinton < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag ross perot < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag ross perot < "$DICT" 2>/dev/null | less -rEXF - -echo "$ ./ag paul e tsongas < $DICT" 1>&2 -read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " -echo 1>&2 -./ag paul e tsongas < "$DICT" 2>/dev/null | less -rEXF diff --git a/2011/akari/try.sh b/2011/akari/try.sh index e8a133bd6..4f5d18766 100755 --- a/2011/akari/try.sh +++ b/2011/akari/try.sh @@ -21,15 +21,18 @@ rm -f akari2 akari3 akari4 clear +echo "Before you begin you might wish to open example.ppm in a graphics viewer." 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 echo 1>&2 +echo "You might care to open odd_output.ppm in a graphics viewer." 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 +echo "You might care to open even_output.ppm in a graphics viewer." 1>&2 read -r -n 1 -p "Press any key to run: ./akari example.ppm odd_output.ppm: " echo 1>&2 diff --git a/2011/blakely/try.sh b/2011/blakely/try.sh index 202a5e0de..bace2ad2c 100755 --- a/2011/blakely/try.sh +++ b/2011/blakely/try.sh @@ -20,9 +20,9 @@ echo 1>&2 ./blakely < 3.dat | head -100 echo 1>&2 -read -r -n 1 -p "Press any key to run: ./blakely - < 3.dat | head -40: " +read -r -n 1 -p "Press any key to run: ./blakely - < 3.dat | head -30: " echo 1>&2 -./blakely - < 3.dat | head -40 +./blakely - < 3.dat | head -30 echo 1>&2 read -r -n 1 -p "Press any key to run: ./blakely < evolve_to_3.dat | head -55: " diff --git a/2011/borsanyi/try.sh b/2011/borsanyi/try.sh index 47959f731..04740c18c 100755 --- a/2011/borsanyi/try.sh +++ b/2011/borsanyi/try.sh @@ -18,14 +18,14 @@ clear 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 +./borsanyi < data.1 | less -rEXFK echo 1>&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 +./borsanyi < data.2 | less -rEXFK echo 1>&2 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 +./borsanyi < data.3 | less -rEXFK diff --git a/2011/hamaji/try.sh b/2011/hamaji/try.sh index 7238fa551..6667a0b9f 100755 --- a/2011/hamaji/try.sh +++ b/2011/hamaji/try.sh @@ -17,7 +17,7 @@ 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 -rEXF +./hamaji < dragon.nono | less -rEXFK echo 1>&2 rm -f dragon dragon2 @@ -27,55 +27,55 @@ if [[ -n "$PERL" && -f "$PERL" && -x "$PERL" ]]; then echo 1>&2 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 + "$PERL" c2nono.pl hamaji.c | ./hamaji | tee dragon | less -rEXFK echo 1>&2 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 + ./hamaji < dragon.nono | tee dragon2 | less -rEXFK 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 + echo "Perl not found, will not run perl related steps." 1>&2 fi rm -f dragon dragon2 echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < random.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < random.nono | less -rEXF +./hamaji < random.nono | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < soccer.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < soccer.nono | less -rEXF +./hamaji < soccer.nono | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < codegolf.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < codegolf.nono | less -rEXF +./hamaji < codegolf.nono | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < face.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < face.nono | less -rEXF +./hamaji < face.nono | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < penguin.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < penguin.nono | less -rEXF +./hamaji < penguin.nono | less -rEXFK 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 -rEXF +./hamaji < samurai.nono | less -rEXFK echo 1>&2 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 | less -rEXF +./hamaji < conway-game-of-life.nono | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < no-solution.nono (no solution): " @@ -90,11 +90,11 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < plus.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < plus.nono | less -rEXF +./hamaji < plus.nono | less -rEXFK echo 1>&2 read -r -n 1 -p "Press any key to run: ./hamaji < smiley.nono (space = next page, q = quit): " echo 1>&2 -./hamaji < smiley.nono | less -rEXF +./hamaji < smiley.nono | less -rEXFK exit 0 diff --git a/2011/hou/try.sh b/2011/hou/try.sh index 7dc584a93..fe3d2b189 100755 --- a/2011/hou/try.sh +++ b/2011/hou/try.sh @@ -6,20 +6,28 @@ # 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 +[[ -z "$CC" ]] && CC="cc" make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -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: grep #define calculator hou.c|cut -f3 -d' ': " +echo 1>&2 +grep '#define calculator' hou.c|cut -f3 -d' ' +echo 1>&2 +read -r -n 1 -p "Press any key to run: grep '11/26+222/31' hou.c: " +echo 1>&2 +grep '11/26+222/31' hou.c +echo 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 +echo "What relation does the equation in the code have to do with the above" 1>&2 +echo "command?" 1>&2 +echo 1>&2 read -r -n 1 -p "Press any key to run: ./hou 'log((21701-19937)-(23209-21701))/log(2)': " echo 1>&2 @@ -45,4 +53,5 @@ echo 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 +echo "Now answer: what does the last one mean? Can you get it to report" 1>&2 +echo "something else?" 1>&2 diff --git a/2011/konno/try.sh b/2011/konno/try.sh index 8d0f0648f..1d39abda0 100755 --- a/2011/konno/try.sh +++ b/2011/konno/try.sh @@ -26,7 +26,7 @@ echo 1>&2 ./konno ioccc echo 1>&2 -read -r -n 1 -p "Press any key to run: ./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 diff --git a/2011/zucker/try.sh b/2011/zucker/try.sh index 03e1f17fa..d8eb1eec0 100755 --- a/2011/zucker/try.sh +++ b/2011/zucker/try.sh @@ -22,14 +22,19 @@ read -r -n 1 -p "Press any key to run: ./zucker > ioccc.ppm: " echo 1>&2 ./zucker > ioccc.ppm echo 1>&2 +echo "Now open ioccc.ppm in a graphics viewer." 1>&2 read -r -n 1 -p "Press any key to run: ./zucker \"Hello!!!\" > hello.ppm: " echo 1>&2 ./zucker "Hello\!\!\!" > hello.ppm +echo "Now open hello.ppm in a graphics viewer." 1>&2 read -r -n 1 -p "Press any key to run: ./zucker faster\! -preview > image2.ppm: " echo 1>&2 ./zucker faster\! -preview > image2.ppm +echo "Now open image2.ppm in a graphics viewer." 1>&2 echo 1>&2 + + diff --git a/2012/zeitak/test.sh b/2012/zeitak/test.sh index 51e81a92f..81ff65b5d 100755 --- a/2012/zeitak/test.sh +++ b/2012/zeitak/test.sh @@ -18,144 +18,47 @@ clear # assume no error: set ERROR to 0 ERROR=0 -read -r -n 1 -p "Press any key to test zeitak.c for nesting errors: " -echo 1>&2 -./zeitak < zeitak.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 3 ]]; then - echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak() +{ + if [[ "$#" != 2 ]]; then + echo "$0: zeitak() expects two args, got: $#" 1>&2 + return + fi -echo "$ cat anonymous.c" 1>&2 -cat anonymous.c -echo 1>&2 -read -r -n 1 -p "Press any key to test anonymous.c for nesting errors: " -echo 1>&2 -./zeitak < anonymous.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 3 ]]; then - echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 + read -r -n 1 -p "Press any key to run show $1 (space = next page, q = quit): " + echo 1>&2 + less -rEXFK "$1" + read -r -n 1 -p "Press any key to test $1 for nesting errors: " + echo 1>&2 + ./zeitak < "$1" + EXIT_CODE="$?" + if [[ "$EXIT_CODE" -ne "$2" ]]; then + echo "Error: did not get exit code $2: $EXIT_CODE" 1>&2 + ERROR=1 + fi + echo 1>&2 +} -echo "$ cat anonymous.alt.c" 1>&2 -cat anonymous.alt.c -echo 1>&2 -read -r -n 1 -p "Press any key to test anonymous.alt.c for nesting errors: " -echo 1>&2 -./zeitak < anonymous.alt.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 3 ]]; then - echo "Error: did not get exit code 3: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak zeitak.c 3 -echo "$ cat incorrect.brace.c" 1>&2 -cat incorrect.brace.c -echo 1>&2 -read -r -n 1 -p "Press any key to test incorrect.brace.c: " -echo 1>&2 -./zeitak < incorrect.brace.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 10 ]]; then - echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak anonymous.c 3 -echo "$ cat incorrect.bracket.c" 1>&2 -cat incorrect.bracket.c -echo 1>&2 -read -r -n 1 -p "Press any key to test incorrect.bracket.c: " -echo 1>&2 -./zeitak < incorrect.bracket.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 10 ]]; then - echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak anonymous.alt.c 3 -echo "$ cat incorrect.paren.c" 1>&2 -cat incorrect.paren.c -echo 1>&2 -read -r -n 1 -p "Press any key to test incorrect.paren.c: " -echo 1>&2 -./zeitak < incorrect.paren.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 10 ]]; then - echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak incorrect.brace.c 10 -echo "$ cat incorrect.quote-esc.c" 1>&2 -cat incorrect.quote-esc.c -echo 1>&2 -read -r -n 1 -p "Press any key to test incorrect.quote-esc.c: " -echo 1>&2 -./zeitak < incorrect.quote-esc.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 10 ]]; then - echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak incorrect.bracket.c 10 -echo "$ cat incorrect.3.quotes.c" 1>&2 -cat incorrect.3.quotes.c -echo 1>&2 -read -r -n 1 -p "Press any key to test incorrect.3.quotes.c: " -echo 1>&2 -./zeitak < incorrect.3.quotes.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 10 ]]; then - echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak incorrect.paren.c 10 -echo "$ cat incorrect.single.quote.c" 1>&2 -cat incorrect.single.quote.c -echo 1>&2 -read -r -n 1 -p "Press any key to test incorrect.single.quote.c: " -echo 1>&2 -./zeitak < incorrect.single.quote.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 10 ]]; then - echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak incorrect.quote-esc.c 10 -echo "$ cat incorrect.1.quote.c" 1>&2 -cat incorrect.1.quote.c -echo 1>&2 -read -r -n 1 -p "Press any key to test incorrect.1.quote.c: " -echo 1>&2 -./zeitak < incorrect.1.quote.c -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 10 ]]; then - echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak incorrect.3.quotes.c 10 -echo "$ cat incorrect.txt" 1>&2 -cat incorrect.txt -echo 1>&2 -read -r -n 1 -p "Press any key to test incorrect.txt: " -echo 1>&2 -./zeitak < incorrect.txt -EXIT_CODE="$?" -if [[ "$EXIT_CODE" -ne 10 ]]; then - echo "Error: did not get exit code 10: $EXIT_CODE" 1>&2 - ERROR=1 -fi -echo 1>&2 +zeitak incorrect.single.quote.c 10 + +zeitak incorrect.1.quote.c 10 + +zeitak incorrect.txt 10 exit "$ERROR" diff --git a/bin/all-run.sh b/bin/all-run.sh index 163abe3f6..628a026ec 100755 --- a/bin/all-run.sh +++ b/bin/all-run.sh @@ -464,7 +464,7 @@ for YYYY in $(< "$TOP_FILE"); do continue fi - # process each entry directroy under YYYY + # process each entry directory under YYYY # export YYYY_DIR for YYYY_DIR in $(< "$YEAR_FILE"); do