From da3bfa5eb0e2c9eef4616ce641a9b3d224b9980a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:05:17 -0800 Subject: [PATCH] Improve 2019/yang/try.sh --- 2019/yang/try.sh | 52 +++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/2019/yang/try.sh b/2019/yang/try.sh index 40efb17bd..2d65b3a15 100755 --- a/2019/yang/try.sh +++ b/2019/yang/try.sh @@ -15,28 +15,28 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear +echo "$ ./prog ioccc.txt a b c d e" 1>&2 read -r -n 1 -p "Press any key to scramble ioccc.txt into five files: " echo 1>&2 -echo "$ ./prog ioccc.txt a b c d e" 1>&2 ./prog ioccc.txt a b c d e -read -r -n 1 -p "Press any key to unscramble part a with cat: " +read -r -n 1 -p "Press any key to unscramble part a with: cat a: " clear cat a -read -r -n 1 -p "Press any key to unscramble part b with cat: " +read -r -n 1 -p "Press any key to unscramble part b with: cat b: " clear cat b -read -r -n 1 -p "Press any key to unscramble part c with cat: " +read -r -n 1 -p "Press any key to unscramble part c with: cat c: " clear cat c -read -r -n 1 -p "Press any key to unscramble part d with cat: " +read -r -n 1 -p "Press any key to unscramble part d with: cat d: " clear cat d -read -r -n 1 -p "Press any key to unscramble part e with cat: " +read -r -n 1 -p "Press any key to unscramble part e with: cat e: " clear cat e @@ -46,8 +46,7 @@ echo 1>&2 cat a b c d e | ./prog echo 1>&2 -echo "$ cat a b c d e | ./prog | diff - ioccc.txt" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: cat a b c d e | ./prog | diff -s - ioccc.txt: " echo 1>&2 cat a b c d e | ./prog | diff -s - ioccc.txt @@ -58,28 +57,29 @@ if [[ "$COLS" -lt 75 || "$LINES" -lt 13 ]]; then exit 0 fi -read -r -n 1 -p "Press any key to scramble sample_input.txt into five files: " echo 1>&2 echo "$ ./prog sample_input.txt a b c d e" 1>&2 +read -r -n 1 -p "Press any key to scramble sample_input.txt into five files: " +echo 1>&2 ./prog sample_input.txt a b c d e -read -r -n 1 -p "Press any key to unscramble part a with cat: " +read -r -n 1 -p "Press any key to unscramble part a with: cat a: " clear cat a -read -r -n 1 -p "Press any key to unscramble part b with cat: " +read -r -n 1 -p "Press any key to unscramble part b with: cat b: " clear cat b -read -r -n 1 -p "Press any key to unscramble part c with cat: " +read -r -n 1 -p "Press any key to unscramble part c with: cat c: " clear cat c -read -r -n 1 -p "Press any key to unscramble part d with cat: " +read -r -n 1 -p "Press any key to unscramble part d with: cat d: " clear cat d -read -r -n 1 -p "Press any key to unscramble part e with cat: " +read -r -n 1 -p "Press any key to unscramble part e with: cat e: " clear cat e @@ -89,11 +89,10 @@ echo 1>&2 cat a b c d e | ./prog echo 1>&2 -echo "$ cat a b c d e | ./prog | diff - sample_input.txt" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: cat a b c d e | ./prog | diff -s - sample_input.txt: " echo 1>&2 cat a b c d e | ./prog | diff -s - sample_input.txt - +echo 1>&2 if [[ "$COLS" -lt 80 || "$LINES" -lt 25 ]]; then # if screen size < 80 x 25 then exit @@ -105,28 +104,28 @@ echo 1>&2 cat prog.c echo 1>&2 +echo "$ ./prog prog.c a b c d e" 1>&2 read -r -n 1 -p "Press any key to scramble prog.c into five files: " echo 1>&2 -echo "$ ./prog prog.c a b c d e" 1>&2 ./prog prog.c a b c d e -read -r -n 1 -p "Press any key to unscramble part a with cat: " +read -r -n 1 -p "Press any key to unscramble part a with: cat a: " clear cat a -read -r -n 1 -p "Press any key to unscramble part b with cat: " +read -r -n 1 -p "Press any key to unscramble part b with: cat b: " clear cat b -read -r -n 1 -p "Press any key to unscramble part c with cat: " +read -r -n 1 -p "Press any key to unscramble part c with: cat c: " clear cat c -read -r -n 1 -p "Press any key to unscramble part d with cat: " +read -r -n 1 -p "Press any key to unscramble part d with: cat d: " clear cat d -read -r -n 1 -p "Press any key to unscramble part e with cat: " +read -r -n 1 -p "Press any key to unscramble part e with: cat e: " clear cat e @@ -136,16 +135,17 @@ echo 1>&2 cat a b c d e | ./prog echo 1>&2 -echo "$ cat a b c d e | ./prog | diff - prog.c" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: cat a b c d e | ./prog | diff -s - prog.c: " echo 1>&2 cat a b c d e | ./prog | diff -s - prog.c +echo 1>&2 # For the next three we have to see if ruby is installed RUBY="$(type -P ruby)" if [[ -n "$RUBY" ]]; then read -r -p "Do you want to see the slow scrambling: ./prog prog.c | ruby prog.c (Y/N)? " + echo 1>&2 if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then echo "This may take a while, hit ctrl-c to exit script." 1>&2 echo 1>&2 @@ -153,6 +153,7 @@ if [[ -n "$RUBY" ]]; then fi read -r -p "Do you want to see the slow scrambling: ./prog violet.c | ruby prog.c (Y/N)? " + echo 1>&2 if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then echo "This may take a while, hit ctrl-c to exit script." 1>&2 echo 1>&2 @@ -160,6 +161,7 @@ if [[ -n "$RUBY" ]]; then fi read -r -p "Do you want to see the slow scrambling: ./prog violet.c | ruby violet.c (Y/N)? " + echo 1>&2 if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then echo "This may take a while, hit ctrl-c to exit script." 1>&2 echo 1>&2