aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-03-04 11:19:15 -0800
committerKaz Kylheku <kaz@kylheku.com>2025-03-04 11:19:15 -0800
commit5757c92613f66caa6d6215a5d089e9efdd4ecf32 (patch)
treef3024a8a0ca1911d133b2ba9a5564e041154d8c8
parent4204a90222c08afb36c90006fb88c04a65a719d8 (diff)
downloadbasta-5757c92613f66caa6d6215a5d089e9efdd4ecf32.tar.gz
basta-5757c92613f66caa6d6215a5d089e9efdd4ecf32.tar.bz2
basta-5757c92613f66caa6d6215a5d089e9efdd4ecf32.zip
fullscreen: use eval to improve appearance of suspended job.
There is a difference between Bash 4 and Bash 5. When a command which has been invoked by syntax like: command "$@" is suspended by Ctrl-Z, Bash 4 shows, as the displayed job string, the real program that is running, and its arguents. Whereas Bash 5 just shows the above unexpanded 'command "$@"' syntax! To work around this, we expand "$@" ourselves, and eval an expanded command. * basta.sh (basta.fullscreen): Expand the command arguments into a properly escaped variable with the help of the %q argument of printf. Then we eval the command. We keep the LINES=$realrows out of the command, putting that into the eval, otherwise that will appear in the jobs also. The cosmetics is improved. For instance if the Bash 5 user has an alias like "alias vim='basta.fullscreen vim'", and then runs "vim file" and suspends the editor into the background, they will see "command vim file" as the job name, rather than LINES=$realrows command "$@".
-rw-r--r--basta.sh3
1 files changed, 2 insertions, 1 deletions
diff --git a/basta.sh b/basta.sh
index 5367c68..b920abd 100644
--- a/basta.sh
+++ b/basta.sh
@@ -332,7 +332,8 @@ basta.fullscreen()
printf $'\e7\e[1;%sr\e8' $realrows >&$ttyfd
stty rows $realrows <&$ttyfd
- LINES=$realrows command "$@" || exit=$?
+ local args=$(printf "%q " "$@")
+ LINES=$realrows eval command $args || exit=$?
if [ $saveterm ] ; then
printf $'\e[?1049l' >&$ttyfd