diff --git a/1985/sicherman/try.alt.sh b/1985/sicherman/try.alt.sh index de1e3ebcc..90ac47ddc 100755 --- a/1985/sicherman/try.alt.sh +++ b/1985/sicherman/try.alt.sh @@ -33,5 +33,10 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c: " echo 1>&2 +# This warning from ShellCheck is incorrect: +# +# SC2094 (info): Make sure not to read and write the same file in the same pipeline. +# +# shellcheck disable=SC2094 ./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c echo "Now explain any differences." 1>&2 diff --git a/1985/sicherman/try.sh b/1985/sicherman/try.sh index 1192b28b5..b515bd274 100755 --- a/1985/sicherman/try.sh +++ b/1985/sicherman/try.sh @@ -33,5 +33,11 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./sicherman < sicherman.c | ./sicherman | diff -s - sicherman.c: " echo 1>&2 + +# This warning from ShellCheck is incorrect: +# +# SC2094 (info): Make sure not to read and write the same file in the same pipeline. +# +# shellcheck disable=SC2094 ./sicherman < sicherman.c | ./sicherman | diff -s - sicherman.c echo "Now explain any differences." 1>&2 diff --git a/1988/dale/try.sh b/1988/dale/try.sh index 132abe136..9b5689add 100755 --- a/1988/dale/try.sh +++ b/1988/dale/try.sh @@ -32,6 +32,14 @@ echo "Why do they differ in the format from the above command? Finally how can y echo "get the more likely desired behaviour?" 1>&2 echo 1>&2 echo 1>&2 +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we deliberately have \\n to show that there will be a newline printed +# WITH printf(1). Thus this does show correct output. +# +# shellcheck disable=SC2028 echo "$ ./dale \$(printf "the following files exist in this directory:\\n%s\\n" *)" read -r -n 1 -p "Press any key to continue: " echo 1>&2 @@ -40,6 +48,14 @@ echo 1>&2 ./dale $(printf "the following files exist in this directory:\n%s\n" *) echo 1>&2 +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we deliberately have \\n to show that there will be a newline printed +# WITH printf(1). Thus this does show correct output. +# +# shellcheck disable=SC2028 echo "$ ./dale \"\$(printf \"the following files exist in this directory:\\n%s\\n\" *)\"" read -r -n 1 -p "Press any key to continue: " echo 1>&2 diff --git a/1993/plummer/try.alt.sh b/1993/plummer/try.alt.sh index 9c4f532fe..5a68767cb 100755 --- a/1993/plummer/try.alt.sh +++ b/1993/plummer/try.alt.sh @@ -12,9 +12,7 @@ fi # let user change the sleep duration if they wish # -if [[ -z "$SLEEP" ]]; then - SLEEP=1000 -fi +[[ -z "$SLEEP" ]] && SLEEP=1000 # let user change the number if they wish to # diff --git a/1993/plummer/try.sh b/1993/plummer/try.sh index e1dde1689..73f2edd83 100755 --- a/1993/plummer/try.sh +++ b/1993/plummer/try.sh @@ -26,7 +26,7 @@ else ARG="$2" fi -make CC="$CC" SLEEP="$SLEEP" all >/dev/null || exit 1 +make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear diff --git a/1994/ldb/try.sh b/1994/ldb/try.sh index e0471b94f..27c6bdf4c 100755 --- a/1994/ldb/try.sh +++ b/1994/ldb/try.sh @@ -26,6 +26,14 @@ ldb_file() ldb_ioccc() { + # This warning from ShellCheck is incorrect: + # + # SC2028 (info): echo may not expand escape sequences. Use printf. + # + # because we deliberately have \\n to show that there will be a newline printed + # WITH printf(1). Thus this does show correct output. + # + # shellcheck disable=SC2028 echo "$ printf \"The International Obfuscated C Code Contest\\nBest One-liner\\nby Laurion Burchall\" | ./ldb" read -r -n 1 -p "Press any key to continue: " echo 1>&2 @@ -33,6 +41,12 @@ ldb_ioccc() echo 1>&2 } +# This warning from ShellCheck is irrelevant as we only use 'i' as an iterator +# to do the commands a number of times: +# +# SC2034 (warning): i appears unused. Verify use (or export if used externally). +# +# shellcheck disable=SC2034 for i in $(seq 1 5); do ldb_file /etc/passwd ldb_ioccc diff --git a/1995/garry/try.alt.sh b/1995/garry/try.alt.sh index 29d812912..3fa9e91b9 100755 --- a/1995/garry/try.alt.sh +++ b/1995/garry/try.alt.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # # try.alt.sh - demonstrate IOCCC winner 1995/garry alt code # @@ -15,6 +15,13 @@ make CC="$CC" alt >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want them to be expanded. This does show correct output. +# +# shellcheck disable=SC2028 echo "$ EXAMPLEON=\"\33\133\61\73\67\155\"; EXAMPLEOFF=\"\33\133\155\"; DOLLAR=\"$\"" 1>&2 EXAMPLEON="\33\133\61\73\67\155" EXAMPLEOFF="\33\133\155" diff --git a/1995/garry/try.sh b/1995/garry/try.sh index 1d3175889..e5548f933 100755 --- a/1995/garry/try.sh +++ b/1995/garry/try.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # # try.sh - demonstrate IOCCC winner 1995/garry # @@ -15,8 +15,14 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear - -echo "$ EXAMPLEON=\"\33\133\61\73\67\155\"; EXAMPLEOFF=\"\33\133\155\"; DOLLAR=\"$\"" 1>&2 +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want them to be expanded. This does show correct output. +# +# shellcheck disable=SC2028 +echo "$ EXAMPLEON=\"\\33\133\61\73\67\155\"; EXAMPLEOFF=\"\33\133\155\"; DOLLAR=\"$\"" 1>&2 EXAMPLEON="\33\133\61\73\67\155" EXAMPLEOFF="\33\133\155" DOLLAR="$" diff --git a/1998/df/try.sh b/1998/df/try.sh index 284ebd4be..bf0113cca 100755 --- a/1998/df/try.sh +++ b/1998/df/try.sh @@ -15,7 +15,7 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -while [[ 1 ]]; do +while :; do read -r -n 1 -p "Press any key to run ./df or 'q' to quit: " echo 1>&2 if [[ "$REPLY" = "q" || "$REPLY" = "Q" ]]; then diff --git a/1998/fanf/try.sh b/1998/fanf/try.sh index 24504d93b..9c244f52d 100755 --- a/1998/fanf/try.sh +++ b/1998/fanf/try.sh @@ -17,9 +17,26 @@ clear read -r -n 1 -p "Press any key to run: echo '((\a(\b(\c(d)))) e)' | ./fanf: " echo 1>&2 + +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want to expand escape sequences. Thus this does show correct +# output. +# +# shellcheck disable=SC2028 echo '((\a(\b(\c(d)))) e)' | ./fanf echo 1>&2 +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want to expand escape sequences. Thus this does show correct +# output. +# +# shellcheck disable=SC2028 echo "$ echo ' (\f\g\x ( @@ -28,6 +45,15 @@ echo "$ echo ' )'|./fanf" 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 + +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want to expand escape sequences. Thus this does show correct +# output. +# +# shellcheck disable=SC2028 echo ' (\f\g\x ( @@ -36,13 +62,36 @@ echo ' )'|./fanf echo 1>&2 - +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want to expand escape sequences. Thus this does show correct +# output. +# +# shellcheck disable=SC2028 echo "$ echo '(\f(\f\g\x( (f((\a(g(b))) e)) (g x) ) K K z))' | ./fanf" 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want to expand escape sequences. Thus this does show correct +# output. +# +# shellcheck disable=SC2028 echo '(\f(\f\g\x( (f((\a(g(b))) e)) (g x) ) K K z))' | ./fanf echo 1>&2 +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want to expand escape sequences. Thus this does show correct +# output. +# +# shellcheck disable=SC2028 echo "$ echo ' (Y\f\n ((= n 0) @@ -53,6 +102,14 @@ echo "$ echo ' read -r -n 1 -p "Press any key to continue: " echo 1>&2 +# This warning from ShellCheck is incorrect: +# +# SC2028 (info): echo may not expand escape sequences. Use printf. +# +# because we don't want to expand escape sequences. Thus this does show correct +# output. +# +# shellcheck disable=SC2028 echo '(Y\f\n ((= n 0) 1 diff --git a/2000/bmeyer/try.sh b/2000/bmeyer/try.sh index d2c59583c..aaa4f6869 100755 --- a/2000/bmeyer/try.sh +++ b/2000/bmeyer/try.sh @@ -19,13 +19,22 @@ clear # be determined: we just use a default value. # # try getting the columns the simple way first: tput cols -COLUMNS="$(tput cols)" -# ^--^ SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. +COLUMNS="$(tputs cols)" +# In this case we might be able to get away with resolving this ShellCheck +# warning: +# +# SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. +# +# but we want to assign the value to COLUMNS and at the same time make sure tput +# worked. Thus we disable this warning. +# # shellcheck disable=SC2181 if [[ "$?" -ne 0 ]]; then # if tput failed for any reason try stty(1) with awk(1): # Disable this warning of shellcheck as it's wrong: awk needs single quotes. - # ^-----------^ SC2016 (info): Expressions don't expand in single quotes, use double quotes for that. + # + # SC2016 (info): Expressions don't expand in single quotes, use double quotes for that. + # # shellcheck disable=SC2016 COLUMNS="$(stty size|awk '{print $NF}')" @@ -74,7 +83,7 @@ echo 1>&2 ./glicbawls "$COLUMNS" < lavabus.pgm > lavabus.glic echo 1>&2 -read -r -n 1 -p "Press any key to run: ./glicbawls -2 "$COLUMNS" < lavabus.pgm > lavabus.glic2: " +read -r -n 1 -p "Press any key to run: ./glicbawls -2 $COLUMNS < lavabus.pgm > lavabus.glic2: " echo 1>&2 ./glicbawls -2 "$COLUMNS" < lavabus.pgm > lavabus.glic2 echo 1>&2 diff --git a/2000/rince/try.sh b/2000/rince/try.sh index 375f04f1d..2ab1eec5e 100755 --- a/2000/rince/try.sh +++ b/2000/rince/try.sh @@ -22,6 +22,14 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./rince 0.001 $(./dmy2jd 7.8 1 1610): " echo 1>&2 + +# ShellCheck is incorrect about: +# +# SC2046 (warning): Quote this to prevent word splitting. +# +# because we actually want word splitting. +# +# shellcheck disable=SC2046 ./rince 0.001 $(./dmy2jd 7.8 1 1610) echo 1>&2 @@ -42,15 +50,36 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 7.8 1 1610): " echo 1>&2 +# ShellCheck is incorrect about: +# +# SC2046 (warning): Quote this to prevent word splitting. +# +# because we actually want word splitting. +# +# shellcheck disable=SC2046 ./rince 0 $(./dmy2jd 7.8 1 1610) echo 1>&2 read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 8.8 1 1610): " echo 1>&2 +# ShellCheck is incorrect about: +# +# SC2046 (warning): Quote this to prevent word splitting. +# +# because we actually want word splitting. +# +# shellcheck disable=SC2046 ./rince 0 $(./dmy2jd 8.8 1 1610) echo 1>&2 read -r -n 1 -p "Press any key to run: ./rince 0 $(./dmy2jd 10.8 1 1610): " echo 1>&2 +# ShellCheck is incorrect about: +# +# SC2046 (warning): Quote this to prevent word splitting. +# +# because we actually want word splitting. +# +# shellcheck disable=SC2046 ./rince 0 $(./dmy2jd 10.8 1 1610) echo 1>&2