fix: terminal stty restore with trap (set -e kills script before restore)
set -e on line 2 causes the bash script to exit immediately when sbcl returns non-zero, before the stty icanon echo ixon restore runs. Add trap cleanup EXIT to guarantee terminal restore on any exit path.
This commit is contained in:
@@ -409,6 +409,10 @@ case "$COMMAND" in
|
||||
(sleep 3) (finish-output)))
|
||||
(uiop:quit 0)
|
||||
LISPEOF
|
||||
# Restore terminal on any exit (set -e can kill the script before the
|
||||
# explicit stty restore below if sbcl exits non-zero).
|
||||
cleanup() { stty icanon echo ixon 2>/dev/null; }
|
||||
trap cleanup EXIT
|
||||
# Capture terminal dimensions in non-standard env vars
|
||||
# (SBCL strips COLUMNS/LINES but leaves MY_* alone).
|
||||
ts=$(stty size 2>/dev/null)
|
||||
@@ -420,9 +424,8 @@ LISPEOF
|
||||
find ~/.cache/common-lisp -name "*.fasl" -path "*cl-tty*" -delete 2>/dev/null
|
||||
sbcl --noinform --load /tmp/tui-load.lisp
|
||||
rc=$?
|
||||
# Restore terminal cooked mode — stty was set to -icanon -echo -ixon
|
||||
# before exec (or sbcl subprocess) to get character-at-a-time input.
|
||||
# Without this restore the terminal stays raw after exit.
|
||||
# Restore terminal cooked mode (also handled by trap cleanup above,
|
||||
# but do it explicitly here for clarity).
|
||||
stty icanon echo ixon 2>/dev/null
|
||||
exit $rc
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user