diff options
author | Abinoam Praxedes Marques Junior <abinoam@gmail.com> | 2019-01-23 15:53:23 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Junior <abinoam@gmail.com> | 2019-01-23 15:53:26 -0300 |
commit | 104be004c62deeb34872f490df253bbba18ed3f4 (patch) | |
tree | 53a9a41efd37d21f7dd2b625aad620ac951f5407 /lib | |
parent | bf489b632afd92c68df0b2c1f348afb66b5495aa (diff) | |
download | highline-104be004c62deeb34872f490df253bbba18ed3f4.tar.gz |
Quick fix for #237
Problem when issueing terminal commands like
`echo = true` in non tty input/outputs.
Like in `echo "asdf" | ruby script.rb`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/highline/terminal/io_console.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/highline/terminal/io_console.rb b/lib/highline/terminal/io_console.rb index e9ff925..0d75079 100644 --- a/lib/highline/terminal/io_console.rb +++ b/lib/highline/terminal/io_console.rb @@ -4,25 +4,32 @@ class HighLine class Terminal # io/console option for HighLine::Terminal. # It's the most used terminal. + # TODO: We're rescuing when not a terminal. + # We should make a more robust implementation. class IOConsole < Terminal # (see Terminal#terminal_size) def terminal_size output.winsize.reverse + rescue Errno::ENOTTY end # (see Terminal#raw_no_echo_mode) def raw_no_echo_mode input.echo = false + rescue Errno::ENOTTY end # (see Terminal#restore_mode) def restore_mode input.echo = true + rescue Errno::ENOTTY end # (see Terminal#get_character) def get_character # rubocop:disable Naming/AccessorMethodName input.getch # from ruby io/console + rescue Errno::ENOTTY + input.getc end end end |