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

Unified Diff: runtime/bin/process_patch.dart

Issue 17261026: Include parent environment by default, add option to not, for Process. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/lib/_internal/pub/lib/src/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_patch.dart
diff --git a/runtime/bin/process_patch.dart b/runtime/bin/process_patch.dart
index b30f449c7d014efa3d7965d73ad03cab902fb67e..65d271f0a1f447cc2786647413181183d62f9790 100644
--- a/runtime/bin/process_patch.dart
+++ b/runtime/bin/process_patch.dart
@@ -20,11 +20,13 @@ patch class Process {
List<String> arguments,
{String workingDirectory,
Map<String, String> environment,
- bool runInShell}) {
+ bool includeParentEnvironment: true,
+ bool runInShell: false}) {
_ProcessImpl process = new _ProcessImpl(executable,
arguments,
workingDirectory,
environment,
+ includeParentEnvironment,
runInShell);
return process._start();
}
@@ -34,13 +36,15 @@ patch class Process {
List<String> arguments,
{String workingDirectory,
Map<String, String> environment,
- bool runInShell,
+ bool includeParentEnvironment: true,
+ bool runInShell: false,
Encoding stdoutEncoding: Encoding.SYSTEM,
Encoding stderrEncoding: Encoding.SYSTEM}) {
return _runNonInteractiveProcess(executable,
arguments,
workingDirectory,
environment,
+ includeParentEnvironment,
runInShell,
stdoutEncoding,
stderrEncoding);
@@ -68,6 +72,7 @@ class _ProcessImpl extends NativeFieldWrapperClass1 implements Process {
List<String> arguments,
String this._workingDirectory,
Map<String, String> environment,
+ bool includeParentEnvironment,
bool runInShell) {
runInShell = identical(runInShell, true);
if (runInShell) {
@@ -101,20 +106,23 @@ class _ProcessImpl extends NativeFieldWrapperClass1 implements Process {
"WorkingDirectory is not a String: $_workingDirectory");
}
- if (environment != null) {
- var env = environment;
- if (env is !Map) {
- throw new ArgumentError("Environment is not a map: $env");
- }
- _environment = [];
- env.forEach((key, value) {
- if (key is !String || value is !String) {
- throw new ArgumentError(
- "Environment key or value is not a string: ($key, $value)");
- }
- _environment.add('$key=$value');
- });
+ _environment = [];
+ if (environment == null) {
+ environment = {};
+ }
+ if (environment is !Map) {
+ throw new ArgumentError("Environment is not a map: $environment");
}
+ if (identical(true, includeParentEnvironment)) {
+ environment = Platform.environment..addAll(environment);
+ }
+ environment.forEach((key, value) {
+ if (key is !String || value is !String) {
+ throw new ArgumentError(
+ "Environment key or value is not a string: ($key, $value)");
+ }
+ _environment.add('$key=$value');
+ });
// stdin going to process.
_stdin = new _StdSink(new _Socket._writePipe());
@@ -331,6 +339,7 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
List<String> arguments,
String workingDirectory,
Map<String, String> environment,
+ bool includeParentEnvironment,
bool runInShell,
Encoding stdoutEncoding,
Encoding stderrEncoding) {
@@ -339,6 +348,7 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
arguments,
workingDirectory: workingDirectory,
environment: environment,
+ includeParentEnvironment: includeParentEnvironment,
runInShell: runInShell).then((Process p) {
int pid = p.pid;
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698