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

Unified Diff: sdk/bin/pub

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
« sdk/bin/dart2js ('K') | « sdk/bin/dartdoc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 $@
« sdk/bin/dart2js ('K') | « sdk/bin/dartdoc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698