Chromium Code Reviews| Index: sdk/lib/io/process.dart |
| diff --git a/sdk/lib/io/process.dart b/sdk/lib/io/process.dart |
| index c1a060a556ffdba90ab40e2047814ff809df194a..381610a566159a17eb0e17a5af342c7f1d0167f6 100644 |
| --- a/sdk/lib/io/process.dart |
| +++ b/sdk/lib/io/process.dart |
| @@ -99,6 +99,43 @@ abstract class Process { |
| List<String> arguments, |
| [ProcessOptions options]); |
|
Søren Gjesse
2013/05/17 14:48:56
This method needs a comment.
Should there be a wa
Anders Johnsen
2013/05/22 07:45:51
Done.
|
| + static Future<ProcessResult> runShell(String executable, |
| + List<String> arguments, |
| + [ProcessOptions options]) |
| + => run(_getShellCommand(), |
| + _getShellArguments(executable, arguments), |
| + options); |
| + |
|
Søren Gjesse
2013/05/17 14:48:56
I am not sure we should have both runShell and she
Anders Johnsen
2013/05/22 07:45:51
Done.
|
| + static Future<ProcessResult> shell(String command, |
|
kustermann
2013/05/21 07:50:00
What is this method doing?
Anders Johnsen
2013/05/22 07:45:51
It's gone.
|
| + [ProcessOptions options]) |
| + => run(_getShellCommand(), |
| + _getShellArguments(command, []), |
| + options); |
| + |
| + static String _getShellCommand() { |
|
Søren Gjesse
2013/05/17 14:48:56
Maybe we should do more extensive search of the sh
Anders Johnsen
2013/05/22 07:45:51
Done.
|
| + if (Platform.operatingSystem == 'windows') { |
| + return "cmd"; |
|
Søren Gjesse
2013/05/17 14:48:56
Should we lookup %COMSPEC% in the Windows environm
Anders Johnsen
2013/05/22 07:45:51
Done.
|
| + } |
| + return "sh"; |
|
Søren Gjesse
2013/05/17 14:48:56
Should we lookup $SHELL in the environment? Should
ricow1
2013/05/21 07:26:34
I don't really care what it defaults to, but I do
kustermann
2013/05/21 07:50:00
The issue here is that different shells might inte
Anders Johnsen
2013/05/22 07:45:51
Done.
|
| + } |
| + |
| + static List<String> _getShellArguments(String executable, |
| + List<String> arguments) { |
| + List<String> shellArguments = []; |
| + if (Platform.operatingSystem == 'windows') { |
| + shellArguments.add("/k"); |
| + } else { |
| + shellArguments.add("-c"); |
| + } |
| + var commandLine = executable; |
| + for (var arg in arguments) { |
| + arg = arg.replaceAll("'", "'\"'\"'"); |
|
Lasse Reichstein Nielsen
2013/05/21 07:31:51
You could use a multiline string here:
"""'"'"'"
Anders Johnsen
2013/05/22 07:45:51
Hehe, I prefer not ;)
|
| + commandLine = "$commandLine '$arg'"; |
|
Lasse Reichstein Nielsen
2013/05/21 07:13:42
Quadratic time string concatenation. Use a StringB
Anders Johnsen
2013/05/22 07:45:51
Done.
|
| + } |
| + shellArguments.add(commandLine); |
| + return shellArguments; |
| + } |
| + |
| /** |
| * Returns the standard output stream of the process as a [:Stream:]. |
| * |