mod_ruby -- Problem with Changing from $defout > $stdout

B

Ben Gribaudo

Hi,

I'm working on upgrading some Ruby 1.6.x to prepare for a web-server
wide upgrade to 1.8.2 (We're still running under 1.6.x). $defout is
obsolete in Ruby 1.8.2. In irb, $defout==$stdout, so I would think that
I should be able to replace any usage of $defout in a script with
$stdout. But it doesn't work!

Take the code below. I would expect to be able use either "$defout =
out" and "$defout = starting_stdout" OR "$stdout = out" and "$stdout =
starting_stdout". However, only the $defout lines work

Interestingly, while $stdout==$defout is true in irb, it is false in
mod_ruby as puts puts ($stdout==$defout)==false true.

What am I doing wrong? Why does $stdout==$defout in irb but not in mod_ruby?

Ben


class ...
def get_output
starting_stdout = $stdout
begin
out = Object.new
class << out
attr_reader :eek:utput
def write(value)
@output ||= ''
@output << value.to_s
end
alias << write
def flush(*args) end
end
## Either of these lines should result in the same effect,
correct?
$defout = out
#$stdout = out
yield
ensure
## Again, these two lines are identical in function, right?
$defout = starting_stdout
#$stdout = starting_stdout
end
puts ($stdout==$defout)==false
return out.output
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top