summaryrefslogtreecommitdiff
path: root/lib/irb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2021-01-19 08:56:51 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2021-01-19 08:57:50 -0800
commit1f87725cae8794e02dde0a662e591ea337f427fa (patch)
tree7364e112bad0f4c3acac0e3e061544f333121b2e /lib/irb
parenteeacdcb9a073c7d8ad703e0dc9faf229a5ebbe3c (diff)
[ruby/irb] Rescue Errno::EINVAL on IRB pp
http://rubyci.s3.amazonaws.com/solaris11-gcc/ruby-master/log/20210119T070008Z.log.html.gz is caused by: /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline/ansi.rb:157:in `winsize': Invalid argument - <STDIN> (Errno::EINVAL) from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline/ansi.rb:157:in `get_screen_size' from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline.rb:168:in `get_screen_size' from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/forwardable.rb:238:in `get_screen_size' from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/irb/color_printer.rb:7:in `pp' from -e:1:in `<main>' https://github.com/ruby/irb/commit/1719514598
Diffstat (limited to 'lib/irb')
-rw-r--r--lib/irb/color_printer.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/irb/color_printer.rb b/lib/irb/color_printer.rb
index 34ba437c87..92afea51cd 100644
--- a/lib/irb/color_printer.rb
+++ b/lib/irb/color_printer.rb
@@ -4,11 +4,21 @@ require 'irb/color'
module IRB
class ColorPrinter < ::PP
- def self.pp(obj, out = $>, width = Reline.get_screen_size.last)
- q = ColorPrinter.new(out, width)
- q.guard_inspect_key {q.pp obj}
- q.flush
- out << "\n"
+ class << self
+ def pp(obj, out = $>, width = screen_width)
+ q = ColorPrinter.new(out, width)
+ q.guard_inspect_key {q.pp obj}
+ q.flush
+ out << "\n"
+ end
+
+ private
+
+ def screen_width
+ Reline.get_screen_size.last
+ rescue Errno::EINVAL # in `winsize': Invalid argument - <STDIN>
+ 79
+ end
end
def text(str, width = nil)