From 281628d5b2621cf2f354f633748e6e73e48ef446 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 13 Feb 2025 22:43:13 -0800 Subject: get_cur_line: don't clobber var on failure. * basta.sh (basta.query_terminal_lines): Streamline by passing received variable name down to get_cur_line, avoding intermediate variable. We don't need a nameref now since we are just passing the name down. (basta.get_cur_line): Do not assign into the variable and test for validity after; test "$2" for validity and only if valid assign to variable. This is taken advantage in basta.fullscreen_alt where the original estimate $realrows is unaffected if query_terminal_lines fails. --- basta.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/basta.sh b/basta.sh index 2d55598..bf999c8 100644 --- a/basta.sh +++ b/basta.sh @@ -16,14 +16,13 @@ basta_deferred_intr=${basta_deferred_intr-} basta.query_terminal_lines() { - local -n intovar=$1 + local intovar=$1 local result local curline printf $'\e7\e[999;999H' - basta.get_cur_line curline + basta.get_cur_line $intovar result=$? printf $'\e8' - intovar=$curline return $result } @@ -66,8 +65,7 @@ basta.get_cur_line() read -t 3 -s -d R response < /dev/tty local IFS="[;" set -- $response - intovar=$2 - [[ "$intovar" =~ ^[0-9]+$ ]] + [[ "$2" =~ ^[0-9]+$ ]] && intovar=$2 } if [ $EPOCHSECONDS ] ; then -- cgit v1.2.3