diff options
author | Abinoam P. Marques Jr <abinoam@gmail.com> | 2023-04-25 21:10:52 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 21:10:52 -0300 |
commit | 51773ff795eea1683a8f210df056a974a8e51211 (patch) | |
tree | ce71b221d7f759d2e199a93e61d557905b6c7815 /lib/highline/terminal/unix_stty.rb | |
parent | b617304aef659d778bd0624e76640f4eaece9bda (diff) | |
parent | ec1885893dc2bb863b4858a110ad86abf7ee4612 (diff) | |
download | highline-51773ff795eea1683a8f210df056a974a8e51211.tar.gz |
Merge pull request #262 from kbrock/silent_tty
Do not call stty on non-tty
Diffstat (limited to 'lib/highline/terminal/unix_stty.rb')
-rw-r--r-- | lib/highline/terminal/unix_stty.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/highline/terminal/unix_stty.rb b/lib/highline/terminal/unix_stty.rb index ad9c85d..df1460b 100644 --- a/lib/highline/terminal/unix_stty.rb +++ b/lib/highline/terminal/unix_stty.rb @@ -20,7 +20,9 @@ class HighLine rescue LoadError end - if /solaris/ =~ RUBY_PLATFORM && + if !@output.tty? + [80, 24] + elsif /solaris/ =~ RUBY_PLATFORM && `stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/ [Regexp.last_match(2), Regexp.last_match(1)].map(&:to_i) elsif `stty size` =~ /^(\d+)\s(\d+)$/ @@ -32,13 +34,13 @@ class HighLine # (see Terminal#raw_no_echo_mode) def raw_no_echo_mode - @state = `stty -g` - system "stty raw -echo -icanon isig" + save_stty + system "stty raw -echo -icanon isig" if input.tty? end # (see Terminal#restore_mode) def restore_mode - system "stty #{@state}" + restore_stty print "\r" end |