Project

General

Profile

Feature #6648

Updated by nobu (Nobuyoshi Nakada) almost 12 years ago

=begin 
 Currently there are no standard mechanisms to get the flags passed to the currently running Ruby implementation. The available mechanisms are not ideal: 

 * Scanning globals and hoping they have not been tweaked to new settings 
 * Using external wrappers to launch Ruby 
 * ??? 

 Inability to get the full set of command-line flags, including flags passed to the VM itself (and probably VM-specific) makes it impossible to launch subprocess Ruby instances with the same settings. 

 A real world example of this is "((%bundle exec%))" "bundle exec" when called with a command line that sets various flags, a la ((%jruby jruby -Xsome.vm.setting --1.9 -S bundle exec%)). exec. None of these flags can propagate to the subprocess, so odd behaviors result. The only option is to put the flags into an env var (((|JRUBY_OPTS|)) (JRUBY_OPTS or ((|RUBYOPT|))) RUBYOPT) but this breaks the flow of calling a simple command line. 

 JRuby provides mechanisms to get all its command line options, but they require calling Java APIs from Ruby's API set. Rubinius provides its own API for accessing comand-line options, but I do not know if it includes VM-level flags as well as standard Ruby flags. 

 I know there is a (({RubyVM})) RubyVM namespace in the 2.0 line. If that namespace is intended to be general-purpose for VM-level features, it would be a good host for this API. Something like... 

   

 class << RubyVM 
     
   def vm_args; end # returns array of command line args *not* passed to the target script 

     

   def script; end # returns the script being executed...though this overlaps with $0 

     

   def script_args; end # returns args passed to the script...though this overlaps with ARGV, but that is perhaps warranted since ARGV can be modified (i.e. you probably want the original args) 
   
 end 
 =end

Back