Skip to content

Commit

Permalink
Provide more information on script resolution
Browse files Browse the repository at this point in the history
Print where we searched for scripts, even when the search yielded
no match.
  • Loading branch information
BanzaiMan committed Nov 28, 2013
1 parent 1056054 commit b317fbd
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions core/src/main/java/org/jruby/util/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,21 +513,21 @@ private String resolveScript(String scriptName) {
// try cwd first
fullName = JRubyFile.create(config.getCurrentDirectory(), scriptName);
if (fullName.exists() && fullName.isFile()) {
if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) {
config.getError().println("Found: " + fullName.getAbsolutePath());
}
logScriptResolutionSuccess(fullName.getAbsolutePath());
return scriptName;
} else {
logScriptResolutionFailure(config.getCurrentDirectory());
}
} catch (Exception e) {
// keep going, try bin/#{scriptName}
}
try {
fullName = JRubyFile.create(config.getJRubyHome(), "bin/" + scriptName);
if (fullName.exists() && fullName.isFile()) {
if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) {
config.getError().println("Found: " + fullName.getAbsolutePath());
}
logScriptResolutionSuccess(fullName.getAbsolutePath());
return fullName.getAbsolutePath();
} else {
logScriptResolutionFailure(config.getJRubyHome() + "/bin");
}
} catch (Exception e) {
// keep going, try PATH
Expand All @@ -543,17 +543,16 @@ private String resolveScript(String scriptName) {
for (int i = 0; i < paths.length; i++) {
fullName = JRubyFile.create(new File(paths[i]).getAbsolutePath(), scriptName);
if (fullName.exists() && fullName.isFile()) {
if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) {
config.getError().println("Found: " + fullName.getAbsolutePath());
}
logScriptResolutionSuccess(fullName.getAbsolutePath());
return fullName.getAbsolutePath();
}
}
logScriptResolutionFailure("PATH=" + path);
}
} catch (Exception e) {
// will fall back to JRuby::Commands
}
if (config.isDebug()) {
if (config.isDebug() || RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) {
config.getError().println("warning: could not resolve -S script on filesystem: " + scriptName);
}
return null;
Expand Down Expand Up @@ -581,5 +580,16 @@ private String grabOptionalValue() {
}
return null;
}


private void logScriptResolutionSuccess(String path) {
if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) {
config.getError().println("Found: " + path);
}
}

private void logScriptResolutionFailure(String path) {
if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) {
config.getError().println("Searched: " + path);
}
}
}

0 comments on commit b317fbd

Please sign in to comment.