From: Robert Dober Date: 2008-02-13T07:37:09+09:00 Subject: Re: Ruby equivalent to source command On Feb 12, 2008 10:28 PM, Joel VanderWerf wrote: > Robert Dober wrote: > > On Feb 12, 2008 7:47 PM, Joel VanderWerf wrote: > >> Brett Williams wrote: > >>> I figured this was the case. I'll go with globals for my context. > >> The horror, the horror. > > I agree, i agree ;) > >> Here's an alternative: http://redshift.sourceforge.net/script. > > It does not seem to handle OP's problem though, which are locals or am I wrong? > > Sorry, I should have made that clear. It uses module_eval, so you don't > get locals, but using module constants and/or methods is better than > globals :) > > I like your hack. One possible pitfall is if the file has __END__. > Another is that local vars can become methods that globally shadow > Kernel/Object methods. For example, add this line to test1.rb: > > open = false very good OP watch out > > Still, I might add this to the script lib as an option to capture locals > in the module. If you do so just substract the Kernel methods (and potentially Objects instance methods) from the locals array to avoid shadowing. I knew I had forgotten something important, thx Joel. R.