stty via /bin/sh -c + stdin redirect instead of -F /dev/tty

The -F flag isn't available on all stty implementations.  Using
shell stdin redirect (stty ... < /dev/tty) via /bin/sh is more
portable and doesn't depend on run-program preserving the
controlling terminal across subprocess boundaries.
This commit is contained in:
Hermes
2026-05-12 01:42:15 +00:00
parent 0ed7427802
commit 613e4b6217

View File

@@ -45,10 +45,12 @@
;;; Terminal raw mode (stty on /dev/tty — portable across Unices)
;;; ---------------------------------------------------------------------------
(defun stty-run (args)
"Run stty with ARGS on the controlling terminal. Returns stdout as string."
"Run stty with ARGS. Returns stdout as string."
(with-output-to-string (s)
(sb-ext:run-program "stty" (append '("-F" "/dev/tty") args)
:output s :input :stdin :wait t)))
(sb-ext:run-program "/bin/sh"
(list "-c" (format nil "stty ~{~a~^ ~} < /dev/tty"
(mapcar #'princ-to-string args)))
:output s :wait t)))
(defun save-terminal-state ()
"Save current terminal settings via stty -g. Returns a string."