Add demo.sh — shell wrapper for raw terminal mode

Raw terminal mode must be set by the parent process (the shell),
not from inside SBCL.  sb-ext:run-program subprocesses cannot
reliably access the controlling terminal for stty operations.
./demo.sh sets raw mode via stty, runs sbcl --script demo.lisp,
and restores terminal state on exit (EXIT, INT, TERM).

demo.lisp no longer calls with-raw-terminal — it assumes the
calling shell has already set raw mode.
This commit is contained in:
Hermes
2026-05-12 01:49:48 +00:00
parent 2b2119a2f1
commit eede03ee3f
3 changed files with 19 additions and 28 deletions

17
demo.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
# cl-tty demo launcher
# Sets raw terminal mode before starting SBCL, restores on exit.
# Raw mode is needed so individual keystrokes are captured instead
# of being line-buffered and echoed by the terminal driver.
SAVED=$(stty -g 2>/dev/null)
if [ -z "$SAVED" ]; then
echo "ERROR: Not running in a real terminal." >&2
exit 1
fi
cleanup() { stty "$SAVED" 2>/dev/null; }
trap cleanup EXIT INT TERM
stty raw -echo -isig -icanon min 1 time 0 2>/dev/null
sbcl --script "$(dirname "$0")/demo.lisp"