summaryrefslogtreecommitdiff
path: root/lib/irb/input-method.rb
diff options
context:
space:
mode:
authorPeter Jones <pjones@devalot.com>2022-03-24 13:48:27 -0700
committergit <svn-admin@ruby-lang.org>2022-06-26 14:40:48 +0900
commite0bfdb23af3f182d7605a6ac3c93b07001d9045c (patch)
tree3fc816a24045a2bb51bab6fb4b5368ca13a44809 /lib/irb/input-method.rb
parent846a6bb60ff5fe085ce90442a11e0dceadf8a0e9 (diff)
[ruby/irb] Ensure stdout is a TTY before calling winsize
When outputting a (possibly truncated) value, IRB will query the window size. However, if IRB was piped to another process, stdout will no longer be a TTY and will not support the `winsize` method. This fix ensure that stdout is a TTY. https://github.com/ruby/irb/commit/125de5eeea
Diffstat (limited to 'lib/irb/input-method.rb')
-rw-r--r--lib/irb/input-method.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 64276e61be..fd68239ee3 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -39,7 +39,7 @@ module IRB
public :gets
def winsize
- if instance_variable_defined?(:@stdout)
+ if instance_variable_defined?(:@stdout) && @stdout.tty?
@stdout.winsize
else
[24, 80]