J
Jim Freeze
Hi
I am writing a tee function for ruby and am pretty close.
The problem I am having now is that I don't know
how to extend $stdout#write and have it survive
a system (or exec) call.
Below is some code illustrating what I have:
def write(a)
super("fred\n")
end
end
$stdout.extend(M)
puts "puts: should be fred" # prints twice for some reason
system("echo", "system: should be fred") # no fred
fred
system: should be fred
If this is not possible, maybe there is a way with alias_method,
but I haven't been able to get that going either.
TIA
I am writing a tee function for ruby and am pretty close.
The problem I am having now is that I don't know
how to extend $stdout#write and have it survive
a system (or exec) call.
Below is some code illustrating what I have:
module Mcat tee.rb
def write(a)
super("fred\n")
end
end
$stdout.extend(M)
puts "puts: should be fred" # prints twice for some reason
system("echo", "system: should be fred") # no fred
fredruby tee.rb
fred
system: should be fred
If this is not possible, maybe there is a way with alias_method,
but I haven't been able to get that going either.
TIA