Skip to content

Commit

Permalink
Get correct script path for macOS (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsk567 authored Nov 7, 2024
1 parent e3659e4 commit 1973c27
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion env.bash
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"

0 comments on commit 1973c27

Please sign in to comment.