Shell wrapper for terminal raw mode, demo no longer sets raw mode
Added ./demo shell script that sets raw mode via stty before running the Lisp demo and restores it on exit (including SIGINT/SIGTERM). demo.lisp no longer attempts to set raw mode from inside SBCL — terminal raw mode is the shell's responsibility. This avoids the recurring problem of sb-ext:run-program + stty not being able to access the controlling terminal from inside sbcl --script.
This commit is contained in:
20
demo
Executable file
20
demo
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# cl-tty demo launcher
|
||||
# Sets raw terminal mode, runs the demo, restores terminal on exit.
|
||||
# This is needed because SBCL's --script mode + run-program combo
|
||||
# can't reliably set raw mode from inside the Lisp process.
|
||||
|
||||
SAVED=$(stty -g 2>/dev/null)
|
||||
if [ -z "$SAVED" ]; then
|
||||
echo "ERROR: Not running in a real terminal." >&2
|
||||
echo " Try: sbcl --script demo.lisp" >&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"
|
||||
Reference in New Issue
Block a user