On Oct 11, 2007, at 22:45 , Fredrik wrote:
You will need to reopen STDOUT to /dev/null
Then I have two more questions to that
- What’s the difference between $stdout and STDOUT? They seem to be
the same thing.
In your case you want to reopen STDOUT because somebody using your
code may have changed $stdout, if they want to capture or redirect
- In my pickaxe book I read that “Assignment to $stdout is
depracated; use $stdout.reopen instead.” But if I want to redirect
$stdout and then $direct it back to what it was before, surely I HAVE
to use assignment to $stdout. Like this:
I don’t think this is true anymore. You can’t reopen using StringIO
to capture regular ruby puts or p.
out = $stdout
$stdout = File.new(’/dev/null’,‘w’)
puts ‘This is not to be seen by anybody.’
If I use reopen on the second line instead, the ‘out’ variable comes
along to this new value and nobody knows where the “usual stdout” is,
Right, you should dup $stdout there.