Skip to content

Commit 66b2905

Browse files
committed
Peel off options hash passed to Open3.popen3.
Fixes #1290. Fixes #1547.
1 parent 0167f3f commit 66b2905

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/src/main/java/org/jruby/util/ShellLauncher.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,13 @@ private static Process popenShared(Ruby runtime, IRubyObject[] strings, Map env,
732732
File pwd = new File(runtime.getCurrentDirectory());
733733

734734
try {
735+
// Peel off env hash, if given
736+
IRubyObject envHash = null;
737+
if (env == null && strings.length > 0 && !(envHash = TypeConverter.checkHashType(runtime, strings[0])).isNil()) {
738+
strings = Arrays.copyOfRange(strings, 1, strings.length);
739+
env = (Map)envHash;
740+
}
741+
735742
String[] args = parseCommandLine(runtime.getCurrentContext(), runtime, strings);
736743
boolean useShell = false;
737744
if (addShell) for (String arg : args) useShell |= shouldUseShell(arg);

0 commit comments

Comments
 (0)