From ee5d57352f0e2ab8659661b4677428405b07ed4a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:26:51 -0800 Subject: [PATCH] Improve 1998/bas2/try.sh --- 1998/bas2/README.md | 2 ++ 1998/bas2/try.sh | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/1998/bas2/README.md b/1998/bas2/README.md index 26916d94b..39a246096 100644 --- a/1998/bas2/README.md +++ b/1998/bas2/README.md @@ -19,6 +19,8 @@ echo text | ./bas2 ./try.sh ./try.sh "foo bar" "baz" "IOCCC 1998/bas2" README.md + +./try.sh try.sh "bas2.c" bas2.orig.c ``` diff --git a/1998/bas2/try.sh b/1998/bas2/try.sh index 2bcacde81..8f0031bee 100755 --- a/1998/bas2/try.sh +++ b/1998/bas2/try.sh @@ -15,30 +15,44 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ ./bas2 < bas2.c" 1>&2 +read -r -n 1 -p "Press any key to run: ./bas2 < bas2.c: " +echo 1>&2 ./bas2 < bas2.c +echo 1>&2 -echo "$ ./bas2 < README.md" 1>&2 +read -r -n 1 -p "Press any key to run: ./bas2 < README.md: " +echo 1>&2 ./bas2 < README.md +echo 1>&2 -echo "$ ./bas2 < Makefile" 1>&2 +read -r -n 1 -p "Press any key to run: ./bas2 < Makefile: " +echo 1>&2 ./bas2 < Makefile +echo 1>&2 -echo "$ echo foo bar baz | ./bas2" 1>&2 +read -r -n 1 -p "Press any key to run: echo foo bar baz | ./bas2: " +echo 1>&2 echo foo bar baz | ./bas2 +echo 1>&2 -echo "$ cat README.md Makefile bas2.c | ./bas2" 1>&2 +read -r -n 1 -p "Press any key to run: cat README.md Makefile bas2.c | ./bas2: " +echo 1>&2 cat README.md Makefile bas2.c | ./bas2 +echo 1>&2 # while we have an arg check if it's a file. If it is a regular file that is # readable feed it to the program; otherwise act as if it's a string. while [[ "$#" -gt 0 ]]; do if [[ -f "$1" && -r "$1" ]]; then - echo "$ ./bas2 < $1" 1>&2 + read -r -n 1 -p "Press any key to run: ./bas2 < $1: " + echo 1>&2 ./bas2 < "$1" + echo 1>&2 else - echo "$ echo $1 | ./bas2" 1>&2 + read -r -n 1 -p "Press any key to run: echo $1 | ./bas2: " + echo 1>&2 echo "$1" | ./bas2 + echo 1>&2 fi shift 1 done