From d9b0786d11d10e24e3597941aeb076e9dc153d93 Mon Sep 17 00:00:00 2001 From: Nuru Date: Tue, 31 Dec 2024 16:14:17 -0800 Subject: [PATCH] Use traps to ensure tty settings get restored --- rootfs/etc/profile.d/_01-launch-warning.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rootfs/etc/profile.d/_01-launch-warning.sh b/rootfs/etc/profile.d/_01-launch-warning.sh index ad46665c..66b60b29 100644 --- a/rootfs/etc/profile.d/_01-launch-warning.sh +++ b/rootfs/etc/profile.d/_01-launch-warning.sh @@ -19,7 +19,10 @@ # so the cursor never advances. Then we eval the message with backspaces removed. # We have to then add some extra characters to erase the eval command. function warn_if_piped() { - local saved_stty=$(stty -g) + local saved_stty + saved_stty=$(stty -g) + trap 'stty "$saved_stty"' EXIT + stty -echo -opost local mesg cmd xb m fx bx feval beval @@ -53,6 +56,7 @@ function warn_if_piped() { echo -n "$beval$feval$beval" stty "$saved_stty" + trap - EXIT } warn_if_piped