From 7ebab0711106a76cace8b81e74f8c540a9a5dc60 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Mon, 24 Apr 2023 15:04:29 -0400 Subject: Use existing save_stty functionality Yes, `save_stty` and `restore_stty` should probably not live in terminal, but they do. No reason to re-implement them. And they handle error cases better. --- lib/highline/terminal/unix_stty.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/highline/terminal/unix_stty.rb b/lib/highline/terminal/unix_stty.rb index ad9c85d..1dbed36 100644 --- a/lib/highline/terminal/unix_stty.rb +++ b/lib/highline/terminal/unix_stty.rb @@ -32,13 +32,13 @@ class HighLine # (see Terminal#raw_no_echo_mode) def raw_no_echo_mode - @state = `stty -g` + save_stty system "stty raw -echo -icanon isig" end # (see Terminal#restore_mode) def restore_mode - system "stty #{@state}" + restore_stty print "\r" end -- cgit v1.2.1