From: Ryan Davis Date: 2009-12-21T19:09:40+09:00 Subject: Re: redirecting stderr in irb 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: > % irb --noreadline 2> x > >> blah > NameError: undefined local variable or method `blah' for main:Object > from (irb):1 > >> ^d > % cat x > % Unfortunately, irb decided to print via STDOUT (which I prefer to keep hands off and play with $stdout only), so messing with it (for me) is a no-no. > class StdioOutputMethod def print(*opts) > STDOUT.print(*opts) > end > end I think what you really want to do is to temporarily reassign output_method in the context.