summaryrefslogtreecommitdiff
path: root/lib/highline/terminal.rb
diff options
context:
space:
mode:
authorKeenan Brock <keenan@thebrocks.net>2023-04-24 15:33:54 -0400
committerKeenan Brock <keenan@thebrocks.net>2023-04-24 15:51:46 -0400
commitec1885893dc2bb863b4858a110ad86abf7ee4612 (patch)
treece71b221d7f759d2e199a93e61d557905b6c7815 /lib/highline/terminal.rb
parent7ebab0711106a76cace8b81e74f8c540a9a5dc60 (diff)
downloadhighline-ec1885893dc2bb863b4858a110ad86abf7ee4612.tar.gz
Do not call stty on non-tty
When testing on a non-tty (e.g.: github actions), either one of these lines produces an error: ```ruby input.echo = true ask("question", "y") { |q| q.readline = true } ``` The error is produced by ruby internals: ```bash echo | rake | cat ......stty: stdin isn't a terminal...... ``` This change skips the stty calls if the input is not on a tty, so the errors will not be produced.
Diffstat (limited to 'lib/highline/terminal.rb')
-rw-r--r--lib/highline/terminal.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/highline/terminal.rb b/lib/highline/terminal.rb
index 550c0c7..bfa0d08 100644
--- a/lib/highline/terminal.rb
+++ b/lib/highline/terminal.rb
@@ -176,7 +176,7 @@ class HighLine
# Saves terminal state using shell stty command.
def save_stty
@stty_save = begin
- `stty -g`.chomp
+ `stty -g`.chomp if input.tty?
rescue StandardError
nil
end