Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1747)

Unified Diff: sdk/bin/dartanalyzer

Issue 15954011: Ensure proper path traversals for linked commands; (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: This patch set fixes / also handles symlinked directories (e.g. sdk/bin) Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« sdk/bin/dart2js ('K') | « sdk/bin/dart2js ('k') | sdk/bin/dartanalyzer_developer » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698