irb icon indicating copy to clipboard operation
irb copied to clipboard

Avoid using arbitrary `puts` to print output

Open st0012 opened this issue 2 years ago • 1 comments

IRB currently prints most of its output to STDOUT by calling puts directly. This means changing the output target is very difficult (e.g. print to a socket instead, which ruby/debug supports).

st0012 avatar May 14 '23 13:05 st0012

I think a possible direction is to:

  1. Make InputMethod act as IOMethod. That is, make it responsible for output too (by adding puts and print methods to it?) as Reline/ReadlineInputMethod both already hold @stdout anyway.
  2. Change all Kernel#puts invocation to irb_context.io.puts (with some refactors, ofc).

st0012 avatar Aug 07 '23 15:08 st0012