aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-02-13 22:43:13 -0800
committerKaz Kylheku <kaz@kylheku.com>2025-02-13 22:43:13 -0800
commit281628d5b2621cf2f354f633748e6e73e48ef446 (patch)
tree03fea8f7c3e7b40858595f5fb25b7478d12c6831
parenta4190442eacb8b8944761aad6d48d9c165b8ce6f (diff)
downloadbasta-281628d5b2621cf2f354f633748e6e73e48ef446.tar.gz
basta-281628d5b2621cf2f354f633748e6e73e48ef446.tar.bz2
basta-281628d5b2621cf2f354f633748e6e73e48ef446.zip
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.
-rw-r--r--basta.sh8
1 files 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