Index: src/org/jruby/environment/OSEnvironment.java =================================================================== --- src/org/jruby/environment/OSEnvironment.java (revision 2576) +++ src/org/jruby/environment/OSEnvironment.java (working copy) @@ -88,13 +88,13 @@ // get environment from jruby command line property supplied class runtime.getWarnings().warn("Getting environment variables using command line defined method: " + jrubyEnvMethod); reader = getAccessibleOSEnvironment(runtime, jrubyEnvMethod); - - envs = null; - if (reader != null) { - Map variables = null; - variables = reader.getVariables(runtime); - envs = getAsMapOfRubyStrings(runtime, variables.entrySet()); - } + } + + envs = null; + if (reader != null) { + Map variables = null; + variables = reader.getVariables(runtime); + envs = getAsMapOfRubyStrings(runtime, variables.entrySet()); } } catch (AccessControlException accessEx) { // default to empty env Index: src/org/jruby/environment/OSEnvironmentReaderFromRuntimeExec.java =================================================================== --- src/org/jruby/environment/OSEnvironmentReaderFromRuntimeExec.java (revision 2576) +++ src/org/jruby/environment/OSEnvironmentReaderFromRuntimeExec.java (working copy) @@ -29,8 +29,7 @@ package org.jruby.environment; import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStreamReader; import java.util.Map; @@ -35,10 +34,6 @@ import java.util.Map; import org.jruby.IRuby; -import org.jruby.RubyKernel; -import org.jruby.RubyString; -import org.jruby.exceptions.RaiseException; -import org.jruby.runtime.builtin.IRubyObject; class OSEnvironmentReaderFromRuntimeExec implements IOSEnvironmentReader { @@ -78,22 +73,16 @@ * @see org.jruby.IOSEnvironment#getVariables() */ public Map getVariables(IRuby runtime) { - - ByteArrayOutputStream output = new ByteArrayOutputStream(); - try { - RubyKernel.runInShell( - runtime, - new IRubyObject[] {RubyString.newString(runtime, getEnvCommand())}, - output); - } catch (RaiseException e) { - environmentReader.handleException(e); - } - - BufferedReader reader = new BufferedReader( - new InputStreamReader(new ByteArrayInputStream(output.toByteArray()))); + Process process = Runtime.getRuntime().exec(getEnvCommand()); + return environmentReader.getVariablesFrom( + new BufferedReader(new InputStreamReader(process.getInputStream())) + ); + } catch (IOException e) { + environmentReader.handleException(e); + } - return environmentReader.getVariablesFrom(reader); + return null; } } Index: test/testEnv.rb =================================================================== --- test/testEnv.rb (revision 2576) +++ test/testEnv.rb (working copy) @@ -1,5 +1,7 @@ require 'test/minirunit' +test_ok(ENV['HOME'], "Reading external environment") + #test_check('test_bracket') test_equal(nil, ENV['test']) test_equal(nil, ENV['TEST'])