Subprocess started by Kernel#exec does not respect RUBYOPT and other 
environment variables set via ENV.
-------------------------------------------------------------------------------------------------------

                 Key: JRUBY-5100
                 URL: http://jira.codehaus.org/browse/JRUBY-5100
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.5.2
         Environment: trunk, Java 6 u20, Mac OS X 10.6.4
            Reporter: Hiro Asari
            Assignee: Hiro Asari


Given files:

{code:title=a.rb|none}
puts "a"
{code}

{code:title=b.rb|none}
puts "b"
{code}

{code:title=x|bash}
#!/usr/bin/env jruby
puts "x"
{code}

in the current working directory, this:

{noformat}
RUBYOPT='-rb' jruby -e 'ENV["RUBYOPT"]="-ra"; exec "jruby x"'
{noformat}
results in:

{noformat}
b
x
{noformat}

MRI returns:
{noformat}
$ RUBYOPT='-rb' ruby -e 'ENV["RUBYOPT"]="-ra"; exec "ruby x"'
b
a
x
{noformat}


The problem is twofold.

# With Kernel#exec, {{RUBYOPT}} does not get processed.
# Even if you insert instructions to process it, e.g.,
{code}
diff --git a/src/org/jruby/util/ShellLauncher.java 
b/src/org/jruby/util/ShellLauncher.java
index 0e24e9d..5487ebd 100644
--- a/src/org/jruby/util/ShellLauncher.java
+++ b/src/org/jruby/util/ShellLauncher.java
@@ -158,6 +158,7 @@ public class ShellLauncher {
                 setEnvironment(environmentMap(env));
                 setCurrentDirectory(pwd.toString());
             }};
+            config.tryProcessArgumentsWithRubyopts();
             if (pipedStreams) {
                 config.setInput(new PipedInputStream(processInput));
                 config.setOutput(new PrintStream(new 
PipedOutputStream(processOutput)));
{code}
the change in {{RUBYOPT}} is not respected. That is, the above execution will 
result in:
{code:none}
$ RUBYOPT='-rb' jruby -e 'ENV["RUBYOPT"]="-ra"; exec "jruby x"'
b
b
x
{code}

-- 
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