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

Unified Diff: sdk/bin/dart2js

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
« no previous file with comments | « no previous file | sdk/bin/dartanalyzer » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/bin/dart2js
diff --git a/sdk/bin/dart2js b/sdk/bin/dart2js
index 96354cae4a715da8d334d30567aa05b23249fbb2..c57436b5a35c470df11ffda58ccb64a2d84bd859 100755
--- a/sdk/bin/dart2js
+++ b/sdk/bin/dart2js
@@ -2,22 +2,19 @@
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-
-function follow_links() {
- while [ -h "$1" ]; do
+function link_dir() {
+ a="$1"
+ while [ -h "$a" ]; do
# On Mac OS, readlink -f doesn't work.
- 1="$(readlink "$1")"
+ a="$(readlink "$a")"
done
- echo "$1"
+ # if dir linked, not file, need to follow dir path:
ahe 2013/05/30 10:00:19 This comment does not make sense to me.
yarkot1 2013/05/31 22:22:17 if $a (filename) is a file, readlink handles follo
ahe 2013/06/03 10:29:01 Could you change the comment to: # If the parent
+ echo "$(cd $(dirname "$a"); pwd -P)"
ahe 2013/05/30 10:00:19 This invokes the external command dirname. That a
yarkot1 2013/05/31 22:22:17 yes - you are correct. Timing this confirms.
}
-# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
-PROG_NAME="$(follow_links "$BASH_SOURCE")"
-
# Handle the case where dart-sdk/bin has been symlinked to.
ahe 2013/05/30 10:00:19 You're still not handling this case.
nweiz 2013/05/31 19:35:21 This case is handled by the "pwd -P" call in link_
ahe 2013/06/03 10:29:01 Thank you. I just studied the man page, and you'r
-BIN_DIR="$(follow_links "$(cd "${PROG_NAME%/*}" ; pwd -P)")"
-
-SDK_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)"
+BIN_DIR="$(link_dir "$0")"
ahe 2013/05/30 10:00:19 $0 is not the right thing to use. See the differe
yarkot1 2013/05/31 22:22:17 yes - this is true in the case of sourced scripts;
+SDK_DIR="${BIN_DIR%/*}"
DART2JS="$SDK_DIR/lib/_internal/compiler/implementation/dart2js.dart"
« no previous file with comments | « no previous file | sdk/bin/dartanalyzer » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698