Don't stty if no terminal attributes.

This commit is contained in:
Alex Shinn 2012-04-17 22:15:56 +09:00
parent 19448ce93a
commit ac704414c6

View file

@ -232,10 +232,15 @@
(define (with-stty setting thunk . o)
(let* ((port (if (pair? o) (car o) (current-input-port)))
(orig-attrs (get-terminal-attributes port)))
(cond
(orig-attrs
(dynamic-wind
(lambda () (stty setting))
thunk
(lambda () (set-terminal-attributes! port TCSANOW orig-attrs)))))
(lambda () (set-terminal-attributes! port TCSANOW orig-attrs))))
(else
;; No terminal attributes means this isn't a tty.
(thunk)))))
;;> Run @var{thunk} with the "raw" (no canonical or echo) options
;;> needed for a terminal application.