Consistently resolve path of jruby.bash #5840
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
The bash script sometimes returns an incorrect path for
JRUBY_HOME
. I came up with a bunch of cases where it would return the wrong directory, in no particular order:Simply replacing
$0
with$BASH_SOURCE
fixes case 3. Obviously this is bash-specific, so this can't be ported to the sh script.Case 4 are solved by using readlink on the executable until it isn't a symlink. The script already did this, so I made some changes to solve other issues.
Cases 1, 2, and 5 are solved by running
pwd -P
in the directory of the executable.I don't know how to solve case 6 without hardcoding a directory to check.
Because
pwd -P
always returns the absolute working directory, it seems runningdirname "$SELF_PATH"
is unnecessary, so I removed it.If anyone can think of any other torture tests, let me know.