Index: sdk/bin/dartanalyzer |
diff --git a/sdk/bin/dartanalyzer b/sdk/bin/dartanalyzer |
index 3f0f947c1e9bca805031fa7c772674857663ff10..af3656b56a7cf0336dfed28ff3821e3e8d21521b 100755 |
--- a/sdk/bin/dartanalyzer |
+++ b/sdk/bin/dartanalyzer |
@@ -8,8 +8,18 @@ set -e |
# Setting SCRIPT_DIR this way is ugly, but is needed to handle the case where |
# dart-sdk/bin has been symlinked to. On MacOS, readlink doesn't work |
# with this case. |
-SCRIPT_DIR="$(cd "${0%/*}" ; pwd -P)" |
-DART_ANALYZER_HOME="$(cd "${SCRIPT_DIR%/*}" ; pwd -P)" |
+function link_dir() { |
+ a="$1" |
+ while [ -h "$a" ]; do |
+ # On Mac OS, readlink -f doesn't work. |
+ a="$(readlink "$a")" |
+ done |
+ # if dir linked, not file, need to follow dir path: |
+ echo $(cd $(dirname $a); pwd -P) |
+} |
+ |
+SCRIPT_DIR="$(link_dir "$0")" |
+DART_ANALYZER_HOME="${SCRIPT_DIR%/*}" |
FOUND_BATCH=0 |
FOUND_SDK=0 |