diff --git a/src/org/jruby/util/cli/ArgumentProcessor.java b/src/org/jruby/util/cli/ArgumentProcessor.java index f47d3e58f6d..2af19cec6e9 100644 --- a/src/org/jruby/util/cli/ArgumentProcessor.java +++ b/src/org/jruby/util/cli/ArgumentProcessor.java @@ -28,18 +28,20 @@ ***** END LICENSE BLOCK *****/ package org.jruby.util.cli; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import org.jruby.CompatVersion; +import org.jruby.Ruby; import org.jruby.RubyInstanceConfig; import org.jruby.exceptions.MainExitException; import org.jruby.util.JRubyFile; import org.jruby.util.KCode; import org.jruby.util.SafePropertyAccessor; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * Encapsulated logic for processing JRuby's command-line arguments. * @@ -496,6 +498,9 @@ private String resolveScript(String scriptName) { } catch (Exception e) { // keep going, try PATH } + if(Ruby.getClassLoader().getResourceAsStream("bin/" + scriptName) != null){ + return "classpath:bin/" + scriptName; + } try { Object pathObj = config.getEnvironment().get("PATH"); String path = pathObj.toString(); diff --git a/test/dir with spaces/testgem.jar b/test/dir with spaces/testgem.jar index 5f212dff577..728de2fe759 100644 Binary files a/test/dir with spaces/testgem.jar and b/test/dir with spaces/testgem.jar differ diff --git a/test/test_jar_complete.rb b/test/test_jar_complete.rb index 409930a0c2d..5a7beb9d8bb 100644 --- a/test/test_jar_complete.rb +++ b/test/test_jar_complete.rb @@ -111,4 +111,10 @@ def test_script_with__FILE__constant_in_jar_with_spaces output = jruby_complete(complete_jar, %{-e "require '_file_constant_'"}).chomp assert output =~ /#{tmp}/, "'#{output}' does not match '#{tmp}'" end + + def test_binscripts_can_be_run_from_classpath + output = `java -cp \"#{COMPLETE_JAR}:test/dir with spaces/testgem.jar\" org.jruby.Main -S testgem` + + assert output == "Testing... 1.. 2.. 3..\n" + end end