From 7013fc901fa09e1eb6c7ad5a24789a18bebc0eed Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 7 Feb 2024 08:41:38 -0800 Subject: [PATCH] Fix 2005/mikeash/try.sh (shellcheck and otherwise) --- 2005/mikeash/try.sh | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/2005/mikeash/try.sh b/2005/mikeash/try.sh index 11488cc55..c79e40722 100755 --- a/2005/mikeash/try.sh +++ b/2005/mikeash/try.sh @@ -18,21 +18,19 @@ clear read -r -n 1 -p "Press any key to run: ./mikeash < mikeash.c (space = next page, q = quit): " echo 1>&2 -./mikeash < mikeash.c +./mikeash < mikeash.c | less -rEXFK echo 1>&2 echo 1>&2 -echo "The next command should print nothing." 1>&2 -read -r -n 1 -p "Press any key to run: ./mikeash < mikeash.c | diff - mikeash.c: " +read -r -n 1 -p "Press any key to run: ./mikeash < mikeash.c | diff -s - mikeash.c: " echo 1>&2 -# ShellCheck is incorrect here: -# -# SC2094 (info): Make sure not to read and write the same file in the same pipeline. -# -# so we disable it. + +# We're not reading and writing to the same file at all. # +# SC2094 (info): Make sure not to read and write the same file in the same pipeline. +# https://www.shellcheck.net/wiki/SC2094 # shellcheck disable=SC2094 -./mikeash < mikeash.c | diff - mikeash.c +./mikeash < mikeash.c | diff -s - mikeash.c echo 1>&2 echo "For the next two commands we will add a newline after the command's output" 1>&2 @@ -45,15 +43,7 @@ echo '(format t "~s" (+ 2 2 ))' | ./mikeash echo 1>&2 echo "The next command will evaluate the expression: (2+2) * (5 - 9/3), giving 8\"." 1>&2 - -# ShellCheck warns: -# -# SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? -# -# ShellCheck is wrong. -# -# shellcheck disable=SC2140 -read -r -n 1 -p "Press any key to run: echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash: " +read -r -n 1 -p "Press any key to run: echo '(format t \"~s\" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash: " echo 1>&2 echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash echo 1>&2