From: Martin DeMello Date: 2009-12-21T19:37:45+09:00 Subject: Re: redirecting stderr in irb On Mon, Dec 21, 2009 at 3:39 PM, Ryan Davis wrote: > > On Dec 21, 2009, at 00:26 , Martin DeMello wrote: > >> Redirecting $stderr in irb doesn't work but redirecting >> $DEFAULT_OUTPUT does. > > "doesn't work" is hardly true. You're certainly redirecting $stderr at the time. What you're confusing is that $DEFAULT_OUTPUT is not an alias for $stderr, but for $stdout. This is easily testable just by playing with the shell: Yeah, i know that, but irb seems to be printing its errors to $DEFAULT_OUTPUT > I think what you really want to do is to temporarily reassign output_method in the context. Well, irb.rb has def output_value if @context.inspect? printf @context.return_format, @context.last_value.inspect else printf @context.return_format, @context.last_value end end So, if I redefine output_method I also need to reopen Irb to override output_value and have it call @context.output_method.printf rather than printf. Anyway I did that, and regular output gets redirected appropriately, but errors don't. It looks like it's hardcoding StdioOutputMethod somewhere, but I couldn't figure out how to override that. martin