On Sat, May 03, 2003 at 01:06:33AM +0900, ahoward wrote:
> so it appears that reopening even $defout results in STDOUT and $stdout also
> being reopened to point to a file.  in otherwords, you will never be able to
> restore unless a copy is made prior to this.

*IF* you use reopen. That associates the same fd with a new file after
closing the old one, so the old stdout is lost for ever. Remember the Ruby
IO object is an abstraction on top of the stdio FILE on top of Unix fd...
File#reopen is essentially a 'mutator' on that object.

But you can do

    $defout = File.open("myfile","w")

in which case you have not touched the $stdout/STDOUT object, you've just
reset $defout to point to a different one.

B.