Fix 2000/bmeyer/try.sh for shellcheck(1)

This commit is contained in:
Cody Boone Ferguson committed 2024-02-05 09:08:03 -08:00
1 parent 838e73e9eb
commit de4d4772ba
1 file changed
+5 -14
+5 -14
View File
@@ -19,22 +19,13 @@ clear
# be determined: we just use a default value.
#
# try getting the columns the simple way first: tput cols
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):
if ! COLUMNS="$(tput cols)"; 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.
# https://www.shellcheck.net/wiki/SC2016
# shellcheck disable=SC2016
COLUMNS="$(stty size|awk '{print $NF}')"