[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
This commit is contained in:
Takashi Kokubun 2021-01-19 08:56:51 -08:00
parent eeacdcb9a0
commit 1f87725cae
1 changed files with 15 additions and 5 deletions

View File

@ -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)