From fe301dc25b7305ff2bed37482f52b473d098919c Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Thu, 14 May 2026 14:20:22 -0400 Subject: [PATCH] fix: run stty size via 'sh -c' with /dev/tty redirection uiop:run-program may redirect the child's stdin, preventing stty from querying the terminal. 'stty size < /dev/tty' explicitly reads from the controlling terminal regardless of stdin setup. --- src/backend/modern.lisp | 6 ++++-- src/backend/simple.lisp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/modern.lisp b/src/backend/modern.lisp index 17254a7..a87fd30 100644 --- a/src/backend/modern.lisp +++ b/src/backend/modern.lisp @@ -174,9 +174,11 @@ as a fallback when a keyword is not in *named-colors*.") (sb-alien:deref winsize 0))) ;; rows (sb-alien:free-alien winsize)))) ;; stty size via subprocess — reliable on every Unix, bypasses - ;; SBCL's alien/ioctl quirks. Returns "ROWS COLS". + ;; SBCL's alien/ioctl quirks. Returns "ROWS COLS". Use sh -c + ;; with explicit /dev/tty to ensure stty sees the real terminal + ;; (uiop:run-program may redirect stdin). (ignore-errors - (let* ((out (uiop:run-program '("stty" "size") + (let* ((out (uiop:run-program '("sh" "-c" "stty size < /dev/tty") :output :string :ignore-error-status t)) (parts (and out (uiop:split-string diff --git a/src/backend/simple.lisp b/src/backend/simple.lisp index 9b1f479..52bdce1 100644 --- a/src/backend/simple.lisp +++ b/src/backend/simple.lisp @@ -36,7 +36,7 @@ (sb-alien:free-alien winsize)))) ;; stty size via subprocess — reliable on every Unix. (ignore-errors - (let* ((out (uiop:run-program '("stty" "size") + (let* ((out (uiop:run-program '("sh" "-c" "stty size < /dev/tty") :output :string :ignore-error-status t)) (parts (and out (uiop:split-string