Index: sdk/bin/pub |
diff --git a/sdk/bin/pub b/sdk/bin/pub |
index 76085ab8b6434cb23c205f9491a0e274ec9c9717..c0fb7a236e706078aae5c0bba7b9c5cf2eeaae53 100755 |
--- a/sdk/bin/pub |
+++ b/sdk/bin/pub |
@@ -5,7 +5,17 @@ |
# Setting BIN_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. |
-BIN_DIR="$(cd "${0%/*}" ; pwd -P)" |
-DART_SDK="$(cd "${BIN_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) |
+} |
+ |
+BIN_DIR="$(link_dir "$0")" |
+DART_SDK="${BIN_DIR%/*}" |
exec "$BIN_DIR"/dart "$DART_SDK"/bin/snapshots/pub.dart.snapshot $@ |