| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 patch class _WindowsCodePageDecoder { | 5 patch class _WindowsCodePageDecoder { |
| 6 /* patch */ static String _decodeBytes(List<int> bytes) | 6 /* patch */ static String _decodeBytes(List<int> bytes) |
| 7 native "SystemEncodingToString"; | 7 native "SystemEncodingToString"; |
| 8 } | 8 } |
| 9 | 9 |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 int len = arguments.length; | 86 int len = arguments.length; |
| 87 _arguments = new List<String>(len); | 87 _arguments = new List<String>(len); |
| 88 for (int i = 0; i < len; i++) { | 88 for (int i = 0; i < len; i++) { |
| 89 var arg = arguments[i]; | 89 var arg = arguments[i]; |
| 90 if (arg is !String) { | 90 if (arg is !String) { |
| 91 throw new ArgumentError("Non-string argument: $arg"); | 91 throw new ArgumentError("Non-string argument: $arg"); |
| 92 } | 92 } |
| 93 _arguments[i] = arguments[i]; | 93 _arguments[i] = arguments[i]; |
| 94 if (Platform.operatingSystem == 'windows') { | 94 if (Platform.operatingSystem == 'windows') { |
| 95 _arguments[i] = _windowsArgumentEscape(_arguments[i], | 95 _arguments[i] = _windowsArgumentEscape(_arguments[i]); |
| 96 shellEscape: runInShell); | |
| 97 } | 96 } |
| 98 } | 97 } |
| 99 | 98 |
| 100 if (_workingDirectory != null && _workingDirectory is !String) { | 99 if (_workingDirectory != null && _workingDirectory is !String) { |
| 101 throw new ArgumentError( | 100 throw new ArgumentError( |
| 102 "WorkingDirectory is not a String: $_workingDirectory"); | 101 "WorkingDirectory is not a String: $_workingDirectory"); |
| 103 } | 102 } |
| 104 | 103 |
| 105 if (environment != null) { | 104 if (environment != null) { |
| 106 var env = environment; | 105 var env = environment; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 shellArguments.add("-c"); | 150 shellArguments.add("-c"); |
| 152 for (var arg in arguments) { | 151 for (var arg in arguments) { |
| 153 arg = arg.replaceAll("'", "'\"'\"'"); | 152 arg = arg.replaceAll("'", "'\"'\"'"); |
| 154 commandLine.write(" '$arg'"); | 153 commandLine.write(" '$arg'"); |
| 155 } | 154 } |
| 156 shellArguments.add(commandLine.toString()); | 155 shellArguments.add(commandLine.toString()); |
| 157 } | 156 } |
| 158 return shellArguments; | 157 return shellArguments; |
| 159 } | 158 } |
| 160 | 159 |
| 161 String _windowsArgumentEscape(String argument, { bool shellEscape: false }) { | 160 String _windowsArgumentEscape(String argument) { |
| 162 var result = argument; | 161 var result = argument; |
| 163 if (argument.contains('\t') || | 162 if (argument.contains('\t') || |
| 164 argument.contains(' ') || | 163 argument.contains(' ') || |
| 165 // TODO(ajohnsen): Remove shellEscape. | 164 argument.contains('"')) { |
| 166 (shellEscape && argument.contains('"'))) { | |
| 167 // Produce something that the C runtime on Windows will parse | 165 // Produce something that the C runtime on Windows will parse |
| 168 // back as this string. | 166 // back as this string. |
| 169 | 167 |
| 170 // Replace any number of '\' followed by '"' with | 168 // Replace any number of '\' followed by '"' with |
| 171 // twice as many '\' followed by '\"'. | 169 // twice as many '\' followed by '\"'. |
| 172 var backslash = '\\'.codeUnitAt(0); | 170 var backslash = '\\'.codeUnitAt(0); |
| 173 var sb = new StringBuffer(); | 171 var sb = new StringBuffer(); |
| 174 var nextPos = 0; | 172 var nextPos = 0; |
| 175 var quotePos = argument.indexOf('"', nextPos); | 173 var quotePos = argument.indexOf('"', nextPos); |
| 176 while (quotePos != -1) { | 174 while (quotePos != -1) { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 const _ProcessResult(int this.pid, | 383 const _ProcessResult(int this.pid, |
| 386 int this.exitCode, | 384 int this.exitCode, |
| 387 this.stdout, | 385 this.stdout, |
| 388 this.stderr); | 386 this.stderr); |
| 389 | 387 |
| 390 final int pid; | 388 final int pid; |
| 391 final int exitCode; | 389 final int exitCode; |
| 392 final stdout; | 390 final stdout; |
| 393 final stderr; | 391 final stderr; |
| 394 } | 392 } |
| OLD | NEW |