Skip to content

Commit

Permalink
Peel off options hash passed to Open3.popen3.
Browse files Browse the repository at this point in the history
Fixes #1290.
Fixes #1547.
  • Loading branch information
headius committed Dec 2, 2014
1 parent 0167f3f commit 66b2905
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/util/ShellLauncher.java
Expand Up @@ -732,6 +732,13 @@ private static Process popenShared(Ruby runtime, IRubyObject[] strings, Map env,
File pwd = new File(runtime.getCurrentDirectory());

try {
// Peel off env hash, if given
IRubyObject envHash = null;
if (env == null && strings.length > 0 && !(envHash = TypeConverter.checkHashType(runtime, strings[0])).isNil()) {
strings = Arrays.copyOfRange(strings, 1, strings.length);
env = (Map)envHash;
}

String[] args = parseCommandLine(runtime.getCurrentContext(), runtime, strings);
boolean useShell = false;
if (addShell) for (String arg : args) useShell |= shouldUseShell(arg);
Expand Down

0 comments on commit 66b2905

Please sign in to comment.