Created
March 10, 2010 22:28
-
-
Save earl/328525 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Launches RingoJS | |
# | |
# find_home - manually emulate GNU's `readlink -f` | |
# | |
function find_home() { | |
# save original working directory | |
ORIG_PWD="$(pwd -P)" | |
# walk the links! we cd into the dir of the binary, read the link target, | |
# make this link our new binary, and start over. we stop as soon as the | |
# binary is no link anymore. | |
T="$1" | |
while true; do | |
cd "$(dirname "$T")" | |
T="$(basename "$T")" | |
if [ ! -L "$T" ]; then | |
break | |
fi | |
T="$(readlink "$T")" | |
done | |
# the final target is in bin/, change to parent and echo as home | |
cd .. | |
echo "$(pwd -P)" | |
# restore original working directory | |
cd "$ORIG_PWD" | |
} | |
if [ -z "$RINGO_HOME" ]; then | |
RINGO_HOME="$(find_home "$0")" | |
fi | |
# prepend rhino to bootclasspath to work around openjdk bug | |
java -Xbootclasspath/p:"$RINGO_HOME/lib/js.jar" -jar "$RINGO_HOME/run.jar" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment