Hello --

On Fri, 29 Dec 2000, Holden Glova wrote:

> Hi all,
> 
> Can anyone explain why I am getting a nil return value from this? I am using 
> backquotes to invoke another Ruby interpreter within the existing interpreter 
> against a specific source file. Here is the class that I am trying to run 
> from the sub-ruby interpreter.
> 
> class Useless
>  
>   def meth
>     puts "Useless method in a useless class"
>   end
>  
> end
>  
> u = Useless.new()
> u.meth()
> 
> Here is the output when run at the command line:
> synack@eugene:~/ruby/rubyide$ ruby -w useless.rb
> Useless method in a useless class
> 
> Now - when I invoke useless.rb through another class through the use of 
> backquotes the result is nil.
>
> class RuntimeInterpreter
>  
>   def invoke(file)
>     `ruby -w #{file} 2>&1`.chomp!
>   end
>  
> end


I'm not clear what you mean by result and/or return value.  The
runtime output of Useless#meth?  and/or the exit status of useless.rb
(as reflect in $?)?  I can get at both, so I can't duplicate your
problem if it's one of those:

   r = RuntimeInterpreter.new
   s = r.invoke("useless.rb")
   p s  # => "Useless method in a useless class"
   p $? # => 0


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav