From 6d32012023c8035c54c120a76519cdb6f7df3dd9 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 6 Feb 2024 03:19:48 -0800 Subject: [PATCH] Fix 1992/westley/whereami scripts if tput fails There was a typo: awkf instead of awk. ShellCheck fix as well. --- 1992/westley/whereami.alt.sh | 18 ++++++++++-------- 1992/westley/whereami.sh | 17 ++++++++++------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/1992/westley/whereami.alt.sh b/1992/westley/whereami.alt.sh index 4356e6790..61bac9c86 100755 --- a/1992/westley/whereami.alt.sh +++ b/1992/westley/whereami.alt.sh @@ -23,16 +23,18 @@ fi # make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it # this way allows us to have the user specify a different compiler in an easy # way. -if [[ -z "$CC" ]]; then - CC="cc" -fi +[[ -z "$CC" ]] && CC="cc" # try getting the columns the simple way first: tput cols -COLUMNS="$(tput cols)" - -if [[ "$?" -ne 0 ]]; then - # if tput failed for any reason try stty(1) with awk(1): - COLUMNS="$(stty size|awkf '{print $NF}')" +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. + # https://www.shellcheck.net/wiki/SC2016 + # shellcheck disable=SC2016 + COLUMNS="$(stty size|awk '{print $NF}')" fi if [[ "$COLUMNS" -lt 80 ]]; then diff --git a/1992/westley/whereami.sh b/1992/westley/whereami.sh index 811ca6474..cf36ebb1a 100755 --- a/1992/westley/whereami.sh +++ b/1992/westley/whereami.sh @@ -23,15 +23,18 @@ fi # make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it # this way allows us to have the user specify a different compiler in an easy # way. -if [[ -z "$CC" ]]; then - CC="cc" -fi +[[ -z "$CC" ]] && CC="cc" # try getting the columns the simple way first: tput cols -COLUMNS="$(tput cols)" -if [[ "$?" -ne 0 ]]; then - # if tput failed for any reason try stty(1) with awk(1): - COLUMNS="$(stty size|awkf '{print $NF}')" +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. + # https://www.shellcheck.net/wiki/SC2016 + # shellcheck disable=SC2016 + COLUMNS="$(stty size|awk '{print $NF}')" fi if [[ "$COLUMNS" -lt 80 ]]; then