-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get correct script path for macOS (#105)
- Loading branch information
Showing
1 changed file
with
15 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
# From https://stackoverflow.com/questions/59895/how-do-i-get-the-directory-where-a-bash-script-is-located-from-within-the-script | ||
FLEXPRET_ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
# The top solution does not work on macOS. | ||
# The solution below comes from this answer: https://stackoverflow.com/a/179231 | ||
pushd . > '/dev/null'; | ||
SCRIPT_PATH="${BASH_SOURCE[0]:-$0}"; | ||
|
||
while [ -h "$SCRIPT_PATH" ]; | ||
do | ||
cd "$( dirname -- "$SCRIPT_PATH"; )"; | ||
SCRIPT_PATH="$( readlink -f -- "$SCRIPT_PATH"; )"; | ||
done | ||
|
||
cd "$( dirname -- "$SCRIPT_PATH"; )" > '/dev/null'; | ||
SCRIPT_PATH="$( pwd; )"; | ||
popd > '/dev/null'; | ||
|
||
FLEXPRET_ROOT=$SCRIPT_PATH | ||
export PATH="$FLEXPRET_ROOT/build/emulator:$PATH" | ||
export FP_PATH="$FLEXPRET_ROOT" | ||
export FP_SDK_PATH="$FLEXPRET_ROOT/sdk" |