From 6f4167373fbad296698cc493124ee13ef1037d9c Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 26 Jan 2024 10:53:05 -0800 Subject: [PATCH] Improve and shellcheck fix 2012/tromp/try.sh As for the shellcheck warning could be fixed (missing '\' before a '"') and the useless cat ones had the rationale updated (it's what the author used so it's easier to verify it's okay though I still say - and so does the script - that there's no such thing as a useless cat) and the format of what warning is disabled (URL included). --- 2012/tromp/try.sh | 86 +++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/2012/tromp/try.sh b/2012/tromp/try.sh index 1b404686b..48680afe4 100755 --- a/2012/tromp/try.sh +++ b/2012/tromp/try.sh @@ -15,106 +15,96 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? -# shellcheck disable=SC2140 -echo "$ (cat hilbert.Blc; echo -n "1") | ./tromp" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: (cat hilbert.Blc; echo -n \"1\") | ./tromp: " echo 1>&2 (cat hilbert.Blc; echo -n "1") | ./tromp echo 1>&2 -# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? -# shellcheck disable=SC2140 -echo "$ (cat hilbert.Blc; echo -n "12") | ./tromp" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: (cat hilbert.Blc; echo -n \"12\") | ./tromp: " echo 1>&2 (cat hilbert.Blc; echo -n "12") | ./tromp echo 1>&2 -# ^-- SC2140 (warning): Word is of the form "A"B"C" (B indicated). Did you mean "ABC" or "A\"B\"C"? -# shellcheck disable=SC2140 -echo "$ (cat hilbert.Blc; echo -n "123") | ./tromp" 1>&2 -read -r -n 1 -p "Press any key to continue: " -echo 1>&2 - -# There's no such thing as a useless cat so we silence: -# -# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# There's no such thing as a useless cat so we silence. Well okay it's also +# because it's easier to verify that it works as this form was given by the +# author. # +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# https://www.shellcheck.net/wiki/SC2002 # shellcheck disable=SC2002 +read -r -n 1 -p "Press any key to run: (cat hilbert.Blc; echo -n \"123\") | ./tromp: " +echo 1>&2 (cat hilbert.Blc; echo -n "123") | ./tromp echo 1>&2 -echo "$ (cat hilbert.Blc; echo -n 1234) | ./tromp" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: (cat hilbert.Blc; echo -n 1234) | ./tromp: " echo 1>&2 -# There's no such thing as a useless cat so we silence: -# -# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# There's no such thing as a useless cat so we silence. Well okay it's also +# because it's easier to verify that it works as this form was given by the +# author. # +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# https://www.shellcheck.net/wiki/SC2002 # shellcheck disable=SC2002 - (cat hilbert.Blc; echo -n 1234) | ./tromp echo 1>&2 -echo "$ echo " Hello, world" | ./tromp" -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: echo \" Hello, world\" | ./tromp: " echo 1>&2 echo " Hello, world" | ./tromp echo 1>&2 -echo "$ echo "*Hello, world" | ./tromp" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: echo \"*Hello, world\" | ./tromp: " echo 1>&2 echo "*Hello, world" | ./tromp echo 1>&2 -echo "$ (cat uni8.Blc; echo " Ni hao") | ./tromp" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: (cat uni8.Blc; echo \" Ni hao\") | ./tromp: " echo 1>&2 -# There's no such thing as a useless cat so we silence: -# -# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. -# -# shellcheck disable=SC2002 (cat uni8.Blc; echo " Ni hao") | ./tromp echo 1>&2 echo "$ cat primes.blc | ./tromp -b | head -c 70" 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 -# There's no such thing as a useless cat so we silence: -# -# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# There's no such thing as a useless cat so we silence. Well okay it's also +# because it's easier to verify that it works as this form was given by the +# author. # +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# https://www.shellcheck.net/wiki/SC2002 # shellcheck disable=SC2002 cat primes.blc | ./tromp -b | head -c 70 echo 1>&2 echo "$ (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70" 1>&2 -echo 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 -# There's no such thing as a useless cat so we silence: -# -# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. + +# There's no such thing as a useless cat so we silence. Well okay it's also +# because it's easier to verify that it works as this form was given by the +# author. # +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# https://www.shellcheck.net/wiki/SC2002 # shellcheck disable=SC2002 (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70 echo 1>&2 -echo "$ cat hw.bf" 1>&2 -read -r -n 1 -p "Press any key to continue: " +read -r -n 1 -p "Press any key to run: cat hw.bf: " echo 1>&2 cat hw.bf echo 1>&2 -echo "$ cat bf.Blc hw.bf | ./tromp" 1>&2 -read -r -n 1 -p "Press any key to continue: " + + +read -r -n 1 -p "Press any key to run: cat bf.Blc hw.bf | ./tromp: " echo 1>&2 -# There's no such thing as a useless cat so we silence: -# -# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# There's no such thing as a useless cat so we silence. Well okay it's also +# because it's easier to verify that it works as this form was given by the +# author. # +# SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. +# https://www.shellcheck.net/wiki/SC2002 # shellcheck disable=SC2002 cat bf.Blc hw.bf | ./tromp