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

Unified Diff: sdk/lib/io/platform_impl.dart

Issue 835863004: Ignore all environment variables with name starting with '=' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 5 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/platform_impl.dart
diff --git a/sdk/lib/io/platform_impl.dart b/sdk/lib/io/platform_impl.dart
index 0cffec6a532bd98f77549122771e11297bec48ff..eaad98af995bdb3119f5e654ba2cd75d7d6b29e1 100644
--- a/sdk/lib/io/platform_impl.dart
+++ b/sdk/lib/io/platform_impl.dart
@@ -58,20 +58,29 @@ class _Platform {
var isWindows = operatingSystem == 'windows';
var result = isWindows ? new _CaseInsensitiveStringMap() : new Map();
for (var str in env) {
- // When running on Windows through cmd.exe there are strange
- // environment variables that are used to record the current
- // working directory for each drive and the exit code for the
- // last command. As an example: '=A:=A:\subdir' records the
- // current working directory on the 'A' drive. In order to
- // handle these correctly we search for a second occurrence of
- // of '=' in the string if the first occurrence is at index 0.
+ // When running on Windows through cmd.exe there are
+ // entries which starts with '='. In CMD scripting,
+ // variables are "dynamic" environment variables which change
+ // automatically. The values of the ones starting with "=" are
+ // reified in the environment string of a new program (but, e.g.,
+ // __CD__ isn't).
+ //
+ // One example are the use of the environment to communicate the
+ // current working directory for each drive and the exit code for the
+ // last command. E.g. the entry '=A:=A:\subdir' records the current
+ // working directory on the 'A' drive.
+ //
+ // On Mac OS an entry of just '=' has been seen.
+ //
+ // Entries starting with '=' are ignored.
+ //
+ // Entries with no '=' should not happen. If it should happen,
+ // the entry is ignored.
var equalsIndex = str.indexOf('=');
- if (equalsIndex == 0) {
- equalsIndex = str.indexOf('=', 1);
+ if (equalsIndex > 0) {
+ result[str.substring(0, equalsIndex)] =
+ str.substring(equalsIndex + 1);
}
- assert(equalsIndex != -1);
- result[str.substring(0, equalsIndex)] =
- str.substring(equalsIndex + 1);
}
_environmentCache = new UnmodifiableMapView<String, String>(result);
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698