forked from GameJs/gamejs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request GameJs#45 from mindeavor/master
Fixed script compatibility for OS X & bash refactor
- Loading branch information
Showing
4 changed files
with
34 additions
and
80 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# | ||
# find_ringo_home - mostly an emulation of GNU's `readlink -f` | ||
# | ||
function find_gamejs_home() { | ||
# save original working directory | ||
ORIG_PWD="$(pwd -P)" | ||
|
||
# walk the links! we cd into the dir of the target binary, read the link, | ||
# make this link our new target, and start over. we stop as soon as the | ||
# target 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" | ||
} |
This file contains 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
This file contains 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