From ff2bb17212b05d23f1651db89735e23dcc70c76d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Tue, 6 Feb 2024 03:24:57 -0800 Subject: [PATCH] Change awk(1) to cut(1) in 1992/westley/whereami* Use of awk(1) is actually overkill and there is already enough overkill if no location is specified: it might nuke the world or the US, depending on submitted entry or alt code (provided in remarks of the author)! :-) --- 1992/westley/whereami.alt.sh | 10 ++-------- 1992/westley/whereami.sh | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/1992/westley/whereami.alt.sh b/1992/westley/whereami.alt.sh index 61bac9c86..04195524b 100755 --- a/1992/westley/whereami.alt.sh +++ b/1992/westley/whereami.alt.sh @@ -27,14 +27,8 @@ fi # try getting the columns the simple way first: tput cols 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}')" + # if tput failed for any reason try stty(1) with cut(1). + COLUMNS="$(stty size|cut -f2 -d' ')" fi if [[ "$COLUMNS" -lt 80 ]]; then diff --git a/1992/westley/whereami.sh b/1992/westley/whereami.sh index cf36ebb1a..f15af4952 100755 --- a/1992/westley/whereami.sh +++ b/1992/westley/whereami.sh @@ -27,14 +27,8 @@ fi # try getting the columns the simple way first: tput cols 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}')" + # if tput failed for any reason try stty(1) with cut(1). + COLUMNS="$(stty size|cut -f2 -d' ')" fi if [[ "$COLUMNS" -lt 80 ]]; then