aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-02-12 19:30:29 -0800
committerKaz Kylheku <kaz@kylheku.com>2025-02-12 19:30:29 -0800
commit71381b41e833e759950e72c5234c06e5924027bd (patch)
tree9917d4c8ed9fcef28be4f1fa4dd2b82b192ac9af
parent431ed945f940c4c526f55096045f603d06787967 (diff)
downloadbasta-71381b41e833e759950e72c5234c06e5924027bd.tar.gz
basta-71381b41e833e759950e72c5234c06e5924027bd.tar.bz2
basta-71381b41e833e759950e72c5234c06e5924027bd.zip
fullscreen: handle stdin/stdout not being a TTY.
* basta.sh (basta.fullscreen, basta.fullscreen_alt): Only perform the special fullscreening logic if the standard input and output are a TTY. If either one is not a TTY, then just run the command and return its status. Otherwise if the program is redirected, the codes we send to the terminal get mixed up in the output. This test isn't perfect, because programs could bre redirected to a TTY which is not the controlling TTY. This is rare to do, and users probably won't be doing this with their basta.fullscreen aliases.
-rw-r--r--basta.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/basta.sh b/basta.sh
index dd07221..c6dd608 100644
--- a/basta.sh
+++ b/basta.sh
@@ -290,6 +290,11 @@ basta.import_array()
# Public API functions
basta.fullscreen() {
+ if ! [ -t 0 -a -t 1 ] ; then
+ command "$@"
+ return $?
+ fi
+
local realrows=$(( LINES + basta_prev_reserved_rows + 1 ))
local exit=
local saveint=$(trap -p INT)
@@ -308,6 +313,11 @@ basta.fullscreen() {
}
basta.fullscreen_alt() {
+ if ! [ -t 0 -a -t 1 ] ; then
+ command "$@"
+ return $?
+ fi
+
local realrows=$(( LINES + basta_prev_reserved_rows + 1 ))
local curline
local i