From 81da08da8d6d30083d0fb1d613fd40511ab414e5 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:18:07 -0800 Subject: [PATCH] Improve 2001/westley/try.sh --- 2001/westley/try.sh | 65 ++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/2001/westley/try.sh b/2001/westley/try.sh index 6490c564d..664af080b 100755 --- a/2001/westley/try.sh +++ b/2001/westley/try.sh @@ -15,40 +15,67 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "./westley < westley.c 2>/dev/null > westley2.c" 1>&2 -./westley < westley.c 2>/dev/null > westley2.c +echo "$ ./westley < westley.c 2>/dev/null | tee westley2.c" 1>&2 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./westley < westley.c 2>/dev/null | tee westley2.c | less -rEXF + echo "Compiling westley2.c..." 1>&2 make CC="$CC" westley2 2>/dev/null 1>&2 -echo +echo 1>&2 echo "$ echo 'Bozos, please deflate shoes before entering the bus!'| ./westley2 2>/dev/null" +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 echo 'Bozos, please deflate shoes before entering the bus!'| ./westley2 2>/dev/null -echo +echo 1>&2 +read -r -n 1 -p "Press any key to run: make CC=\"$CC\" westley.sort 2>/dev/null: " +echo 1>&2 make CC="$CC" westley.sort 2>/dev/null 1>&2 -echo -echo "./westley.sort < westley.c 2>/dev/null | diff - westley.c" +echo 1>&2 + +echo "$ ./westley.sort < westley.c 2>/dev/null | diff -s - westley.c" +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 # SC2094 (info): Make sure not to read and write the same file in the same pipeline. # shellcheck disable=SC2094 -./westley.sort < westley.c 2>/dev/null | diff - westley.c -echo "./westley.sort < westley.c 2>/dev/null | diff - westley2.c" -./westley.sort < westley.c 2>/dev/null | diff - westley2.c -echo "./westley.sort < westley.c 2>/dev/null | diff - westley.sort.c" -./westley.sort < westley.c 2>/dev/null | diff - westley.sort.c -echo "./westley.sort < westley.c 2>/dev/null | diff - westley.punch.c" -./westley.sort < westley.c 2>/dev/null | diff - westley.punch.c +./westley.sort < westley.c 2>/dev/null | diff -s - westley.c | less -rEXF +echo 1>&2 -echo +echo "$ ./westley.sort < westley.c 2>/dev/null | diff - westley2.c" +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./westley.sort < westley.c 2>/dev/null | diff -s - westley2.c | less -rEXF +echo 1>&2 + +echo "$ ./westley.sort < westley.c 2>/dev/null | diff - westley.sort.c" +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./westley.sort < westley.c 2>/dev/null | diff - westley.sort.c | less -rEXF +echo 1>&2 + +echo "$ ./westley.sort < westley.c 2>/dev/null | diff - westley.punch.c" +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./westley.sort < westley.c 2>/dev/null | diff - westley.punch.c | less -rEXF + +echo 1>&2 # SC2028 (info): echo may not expand escape sequences. Use printf. # shellcheck disable=SC2028 -echo "printf \"1\n\4\n5\" | ./westley 2>/dev/null" +read -r -n 1 -p "Press any key to run: printf \"1\n\4\n5\" | ./westley 2>/dev/null: " +echo 1>&2 printf "1\n4\n5" | ./westley 2>/dev/null +echo 1>&2 -echo +echo 1>&2 # SC2028 (info): echo may not expand escape sequences. Use printf. # shellcheck disable=SC2028 -echo "printf \"1\n4\n5\" | ./westley 2>/dev/null" +read -r -n 1 -p "Press any key to run: printf \"1\n4\n5\" | ./westley 2>/dev/null: " +echo 1>&2 printf "1\n4\n5" | ./westley 2>/dev/null +echo 1>&2 -echo -echo "echo 'Hello, world!' | ./westley.punch 2>/dev/null" +echo 1>&2 +read -r -n 1 -p "Press any key to run: echo 'Hello, world!' | ./westley.punch 2>/dev/null: " +echo 1>&2 echo 'Hello, world!' | ./westley.punch 2>/dev/null