JRuby shebang parsing is too simplistic
---------------------------------------

                 Key: JRUBY-3620
                 URL: http://jira.codehaus.org/browse/JRUBY-3620
             Project: JRuby
          Issue Type: Bug
          Components: Interpreter
    Affects Versions: JRuby 1.2
         Environment: Solaris 10
            Reporter: Clayton O'Neill
            Priority: Minor
         Attachments: shebang.patch

JRuby goes to some length in parseShebangOptions to try to find additional 
command-line options that have been specified as part of the shebang line.  The 
current processing is too simplistic and assumes the first incidence of the 
string "ruby" is going to be the end of the specification of the interpreter.  
This fails if you have the jruby binary in a directory with the word "ruby" in 
it (ie, "/sw/jruby/jruby-1.2.0/bin/jruby")  This will cause all command-line 
processing to fail in at least some circumstances, in a very non-obvious way.

This is fundamentally an unsolvable problem since it's impossible to know what 
chain of commands may lead to the interpreter to being invoked.  The attached 
patch changes the parseShebangOptions method to be somewhat smarter about 
common scenarios.  If the first part of the commandline ends in /env, then it 
assumes then some flavor of /usr/bin/env has been invoked, and skips all 
arguments that start with - or contain =.  It continues with this until it 
finds a argument given where File.getName() returns a string that contains 
"ruby".  It then returns everything past this.  

This should cover all of the previous scenarios (such as jruby.bat being 
hardcoded), and behave better for several others.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to