Skip to content

Commit

Permalink
Rescue Errno::EINVAL on IRB pp
Browse files Browse the repository at this point in the history
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>'
  • Loading branch information
k0kubun committed Jan 19, 2021
1 parent ea87592 commit 1719514
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/irb/color_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@

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)
Expand Down

0 comments on commit 1719514

Please sign in to comment.