diff --git a/passepartout b/passepartout index 17b02ba..3d9de1e 100755 --- a/passepartout +++ b/passepartout @@ -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 ;;