Chromium Code Reviews| Index: runtime/bin/process_patch.dart |
| diff --git a/runtime/bin/process_patch.dart b/runtime/bin/process_patch.dart |
| index ba50c9f5a0e67730efd96c42b63bdc4668a311a1..659479b88e446d0ad9084b1a5ae5344c58f0f761 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) { |
| @@ -102,20 +107,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 (identical(true, includeParentEnvironment)) { |
| + environment = Platform.environment..addAll(environment); |
| } |
|
Søren Gjesse
2013/06/20 20:15:50
I think this type check needs to be before the if
Anders Johnsen
2013/06/21 06:44:09
Done.
|
| + if (environment is !Map) { |
| + throw new ArgumentError("Environment is not a map: $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()); |
| @@ -333,6 +341,7 @@ Future<ProcessResult> _runNonInteractiveProcess(String path, |
| List<String> arguments, |
| String workingDirectory, |
| Map<String, String> environment, |
| + bool includeParentEnvironment, |
| bool runInShell, |
| Encoding stdoutEncoding, |
| Encoding stderrEncoding) { |
| @@ -341,6 +350,7 @@ Future<ProcessResult> _runNonInteractiveProcess(String path, |
| arguments, |
| workingDirectory: workingDirectory, |
| environment: environment, |
| + includeParentEnvironment: includeParentEnvironment, |
| runInShell: runInShell).then((Process p) { |
| int pid = p.pid; |