diff --git a/1985/shapiro/try.alt.sh b/1985/shapiro/try.alt.sh index ecc3db809..ac8182cfa 100755 --- a/1985/shapiro/try.alt.sh +++ b/1985/shapiro/try.alt.sh @@ -37,9 +37,8 @@ done # it either. while :; do read -r -p "Enter a value (any non-digit = quit): " - # ^-- SC2143 (style): Use grep -q instead of comparing output with [ -n .. ]. - # shellcheck disable=SC2143 - if [[ $(echo "$REPLY" | grep -E '\<[0-9]+\>') ]]; then + GREP_REPLY=$(echo "$REPLY" | grep -E '\<[0-9]+\>') + if [[ -z $GREP_REPLY ]]; then make clobber CC="$CC" SIZE="$REPLY" alt >/dev/null ./shapiro.alt else diff --git a/1985/sicherman/try.alt.sh b/1985/sicherman/try.alt.sh index 756e07502..0064d4458 100755 --- a/1985/sicherman/try.alt.sh +++ b/1985/sicherman/try.alt.sh @@ -35,8 +35,8 @@ read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sic 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. -# +# 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 ./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 672509829..d40fa16d0 100755 --- a/1985/sicherman/try.sh +++ b/1985/sicherman/try.sh @@ -36,8 +36,8 @@ 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. -# +#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 ./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 aa1a3afc9..69c04deae 100755 --- a/1988/dale/try.sh +++ b/1988/dale/try.sh @@ -22,7 +22,10 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ./dale these files are in this directory: *: " echo 1>&2 +# We need * and do not care about dashes +# # SC2035 (info): Use ./*glob* or -- *glob* so names with dashes won't become options. +# https://www.shellcheck.net/wiki/SC2035 # shellcheck disable=SC2035 ./dale these files are in this directory: * echo 1>&2 @@ -32,29 +35,28 @@ 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. +# This warning from ShellCheck is incorrect because we deliberately have \\n to show that +# there will be a newline printed WITH printf(1). Thus this does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # 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 +# We do not care about word splitting in this case. +# # SC2046 (warning): Quote this to prevent word splitting. +# https://www.shellcheck.net/wiki/SC2046 # shellcheck disable=SC2046 ./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. +# This warning from ShellCheck is incorrect because we deliberately have \\n to show that +# there will be a newline printed WITH printf(1). Thus this does show correct output. # +#SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # 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: " diff --git a/1990/theorem/try.sh b/1990/theorem/try.sh index 478085704..7e13b4947 100755 --- a/1990/theorem/try.sh +++ b/1990/theorem/try.sh @@ -36,7 +36,10 @@ echo 1>&2 read -r -n 1 -p "Press any key to run: ls | ./sorter > ls.sorted.txt: " echo 1>&2 +# We do want to process the ls command output. +# # SC2012 (info): Use find instead of ls to better handle non-alphanumeric filenames. +# https://www.shellcheck.net/wiki/SC2012 # shellcheck disable=SC2012 ls | ./sorter > ls.sorted.txt diff --git a/1991/westley/ttt.alt.sh b/1991/westley/ttt.alt.sh index 92146f8d1..5d1159ffd 100755 --- a/1991/westley/ttt.alt.sh +++ b/1991/westley/ttt.alt.sh @@ -163,6 +163,7 @@ else # For anything else, game in progress, do not do anything # SC2006 (style): Use $(...) notation instead of legacy backticks `...`. + # https://www.shellcheck.net/wiki/SC2006 # shellcheck disable=SC2006 if [[ -n "`grep ':-(' ttt.alt_game.c`" ]]; then echo @@ -172,6 +173,7 @@ else rm -f merlyn ttt.alt_game else # SC2006 (style): Use $(...) notation instead of legacy backticks `...`. + # https://www.shellcheck.net/wiki/SC2006 # shellcheck disable=SC2006 if [[ -n "`grep ':-)' ttt.alt_game.c`" ]]; then echo @@ -180,6 +182,7 @@ else rm -f ttt.alt_game else # SC2006 (style): Use $(...) notation instead of legacy backticks `...`. + # https://www.shellcheck.net/wiki/SC2006 # shellcheck disable=SC2006 if [[ -z "`grep 'X=-. ' ttt.alt_game.c`" && -z "`grep '^. ' ttt.alt_game.c`" ]]; then echo diff --git a/1991/westley/ttt.sh b/1991/westley/ttt.sh index 66e6ae532..30b2a6141 100755 --- a/1991/westley/ttt.sh +++ b/1991/westley/ttt.sh @@ -163,6 +163,7 @@ else # For anything else, game in progress, do not do anything # SC2006 (style): Use $(...) notation instead of legacy backticks `...`. + # https://www.shellcheck.net/wiki/SC2006 # shellcheck disable=SC2006 if [[ -n "`grep ':-(' ttt_game.c`" ]]; then echo @@ -172,6 +173,7 @@ else rm -f merlyn ttt_game else # SC2006 (style): Use $(...) notation instead of legacy backticks `...`. + # https://www.shellcheck.net/wiki/SC2006 # shellcheck disable=SC2006 if [[ -n "`grep ':-)' ttt_game.c`" ]]; then echo @@ -180,6 +182,7 @@ else rm -f ttt_game else # SC2006 (style): Use $(...) notation instead of legacy backticks `...`. + # https://www.shellcheck.net/wiki/SC2006 # shellcheck disable=SC2006 if [[ -z "`grep 'X=-. ' ttt_game.c`" && -z "`grep '^. ' ttt_game.c`" ]]; then echo diff --git a/1994/ldb/try.sh b/1994/ldb/try.sh index 0d7197a57..c756813ad 100755 --- a/1994/ldb/try.sh +++ b/1994/ldb/try.sh @@ -26,13 +26,11 @@ 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. + # This warning from ShellCheck is incorrect because we deliberately have \\n to show + # that there will be a newline printed WITH printf(1). Thus this does show correct output. # + # SC2028 (info): echo may not expand escape sequences. Use printf. + # https://www.shellcheck.net/wiki/SC2028 # 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: " @@ -44,8 +42,8 @@ ldb_ioccc() # 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). -# +# SC2034 (warning): i appears unused. Verify use (or export if used externally). +# https://www.shellcheck.net/wiki/SC2034 # shellcheck disable=SC2034 for i in $(seq 1 5); do ldb_file /etc/passwd diff --git a/1995/garry/try.alt.sh b/1995/garry/try.alt.sh index fbe3c5b73..c58eea046 100755 --- a/1995/garry/try.alt.sh +++ b/1995/garry/try.alt.sh @@ -15,12 +15,11 @@ 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. +# This warning from ShellCheck is incorrect because we don't want them to be expanded. +# This does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # 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" diff --git a/1995/garry/try.sh b/1995/garry/try.sh index decbc72aa..12252244c 100755 --- a/1995/garry/try.sh +++ b/1995/garry/try.sh @@ -15,12 +15,11 @@ make CC="$CC" all >/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. +# This warning from ShellCheck is incorrect because we don't want them to be expanded. +# This does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # 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" diff --git a/1998/fanf/try.sh b/1998/fanf/try.sh index 1695fac6e..4db3bcc38 100755 --- a/1998/fanf/try.sh +++ b/1998/fanf/try.sh @@ -18,24 +18,20 @@ 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. +# This warning from ShellCheck is incorrect because we don't want to expand escape sequences. +# Thus this does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # 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. +# This warning from ShellCheck is incorrect because we don't want to expand escape sequences. +# Thus this does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # shellcheck disable=SC2028 echo "$ echo ' (\f\g\x @@ -46,13 +42,11 @@ 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. +# This warning from ShellCheck is incorrect because we don't want to expand escape sequences. +# Thus this does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # shellcheck disable=SC2028 echo ' (\f\g\x @@ -62,35 +56,29 @@ 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. +# This warning from ShellCheck is incorrect because we don't want to expand escape sequences. +# Thus this does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # 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. +# This warning from ShellCheck is incorrect because we don't want to expand escape sequences. +# Thus this does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # 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. +# This warning from ShellCheck is incorrect because we don't want to expand escape sequences. +# Thus this does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # shellcheck disable=SC2028 echo "$ echo ' (Y\f\n @@ -102,13 +90,11 @@ 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. +# This warning from ShellCheck is incorrect because we don't want to expand escape sequences. +# Thus this does show correct output. # +# SC2028 (info): echo may not expand escape sequences. Use printf. +# https://www.shellcheck.net/wiki/SC2028 # shellcheck disable=SC2028 echo '(Y\f\n ((= n 0) diff --git a/2001/westley/try.sh b/2001/westley/try.sh index 64a12c206..1b1cf518b 100755 --- a/2001/westley/try.sh +++ b/2001/westley/try.sh @@ -36,7 +36,10 @@ 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 +# There isn't a read and write problem. +# # 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 ./westley.sort < westley.c 2>/dev/null | diff -s - westley.c | less -rEXFK echo 1>&2 diff --git a/2015/howe/avgtime.sh b/2015/howe/avgtime.sh index 677a92a60..8dd72f3ae 100755 --- a/2015/howe/avgtime.sh +++ b/2015/howe/avgtime.sh @@ -6,7 +6,8 @@ if [[ "$#" -lt 2 ]]; then fi COUNT=$1; shift -# ^--^ SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. +# SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. +# https://www.shellcheck.net/wiki/SC2124 # shellcheck disable=SC2124 CMD="$@" @@ -16,20 +17,27 @@ USER=0 REAL=0 while [[ $N -lt $COUNT ]]; do - # ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. # 'fixing' this will break the script so we disable it: + # + # SC2086 (info): Double quote to prevent globbing and word splitting. + # https://www.shellcheck.net/wiki/SC2086 # shellcheck disable=SC2086 TIME=$( { /usr/bin/time -l $CMD >/dev/null; } 2>&1 | head -n 1 ) - # ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. # 'fixing' this will break the script so we disable it: + # + # SC2086 (info): Double quote to prevent globbing and word splitting. + # https://www.shellcheck.net/wiki/SC2086 # shellcheck disable=SC2086 REAL="$REAL + $(echo $TIME | cut -d' ' -f1)" - # ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. # 'fixing' this will break the script so we disable it: + # + # SC2086 (info): Double quote to prevent globbing and word splitting. # shellcheck disable=SC2086 USER="$USER + $(echo $TIME | cut -d' ' -f3)" - # ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. # 'fixing' this will break the script so we disable it: + # + # SC2086 (info): Double quote to prevent globbing and word splitting. + # https://www.shellcheck.net/wiki/SC2086 # shellcheck disable=SC2086 SYS="$SYS + $(echo $TIME | cut -d' ' -f5)" ((N++))