Index: sdk/bin/dartdoc |
diff --git a/sdk/bin/dartdoc b/sdk/bin/dartdoc |
index 3f223678f655240fa886e78badda0250211bdfb8..0b00408468262d87b9303aaffaac1360fe516b5c 100755 |
--- a/sdk/bin/dartdoc |
+++ b/sdk/bin/dartdoc |
@@ -6,7 +6,16 @@ |
# 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)" |
+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")" |
unset COLORS |
if test -t 1; then |