From: Jesse Merriman Date: 2008-09-05T07:09:04+09:00 Subject: Re: [SUMMARY] Where the Required Things Are (#175) > the two "complete" solutions (Merriman, Suchanek) could quite > possibly be broken on other platforms. I don't know. (I'm a bit > occupied this week.:) A 100% solid solution should account for all > these things. Both Michal's and mine work on my Linux box: jesse@ricercar $ uname -a Linux ricercar 2.6.25-gentoo-r7 #2 SMP PREEMPT Thu Aug 14 18:28:35 EDT 2008 i686 Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz GenuineIntel GNU/Linux jesse@ricercar $ ruby -v ruby 1.8.6 (2008-03-03 patchlevel 114) [i686-linux] > Finally, most of you should recognize the standard technique for > knowing when a script is run rather than loaded via `require`: > >     if __FILE__ == $0 >       ARGV.each { |mod| require mod } >     end There is some danger though... jesse@ricercar $ ./modwhich.rb modwhich.rb ./modwhich.rb:8:in `require_orig': stack level too deep (SystemStackError) from ./modwhich.rb:8:in `require_orig' from ./modwhich.rb:8:in `require' from ./modwhich.rb:25 from ./modwhich.rb:25:in `each' from ./modwhich.rb:25 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require_orig' from ./modwhich.rb:8:in `require' from ./modwhich.rb:25 from ./modwhich.rb:25:in `each' from ./modwhich.rb:25 -- Jesse Merriman