Change awk to cut in 2000/bmeyer/try.sh

This commit is contained in:
Cody Boone Ferguson committed 2024-02-06 03:28:43 -08:00
1 parent ff2bb17212
commit 16473d3633
1 file changed
+6 -11
+6 -11
View File
@@ -19,17 +19,12 @@ clear
# be determined: we just use a default value.
#
# 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 [[ "$?" -ne 0 ]]; then
if COLUMNS="$(tput cols)"; then
# if tput failed for any reason try stty(1) with cut(1).
COLUMNS="$(stty size|cut -f2 -d' ')"
# if however either stty size or cut fails, set to 150.
if [[ "${PIPESTATUS[0]}" -ne 0 || "${PIPESTATUS[1]}" -ne 0 ]]; then
COLUMNS=150
fi
fi