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

Side by Side Diff: runtime/bin/process_patch.dart

Issue 15782003: Use correct path escape on Windows, for Process. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/standalone/io/process_shell_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return '/bin/sh'; 133 return '/bin/sh';
134 } 134 }
135 135
136 static List<String> _getShellArguments(String executable, 136 static List<String> _getShellArguments(String executable,
137 List<String> arguments) { 137 List<String> arguments) {
138 List<String> shellArguments = []; 138 List<String> shellArguments = [];
139 if (Platform.operatingSystem == 'windows') { 139 if (Platform.operatingSystem == 'windows') {
140 shellArguments.add('/c'); 140 shellArguments.add('/c');
141 shellArguments.add(executable); 141 shellArguments.add(executable);
142 for (var arg in arguments) { 142 for (var arg in arguments) {
143 arg = arg.replaceAll('"', r'\"');
144 shellArguments.add(arg); 143 shellArguments.add(arg);
145 } 144 }
146 } else { 145 } else {
147 var commandLine = new StringBuffer(); 146 var commandLine = new StringBuffer();
148 executable = executable.replaceAll("'", "'\"'\"'"); 147 executable = executable.replaceAll("'", "'\"'\"'");
149 commandLine.write("'$executable'"); 148 commandLine.write("'$executable'");
150 shellArguments.add("-c"); 149 shellArguments.add("-c");
151 for (var arg in arguments) { 150 for (var arg in arguments) {
152 arg = arg.replaceAll("'", "'\"'\"'"); 151 arg = arg.replaceAll("'", "'\"'\"'");
153 commandLine.write(" '$arg'"); 152 commandLine.write(" '$arg'");
154 } 153 }
155 shellArguments.add(commandLine.toString()); 154 shellArguments.add(commandLine.toString());
156 } 155 }
157 return shellArguments; 156 return shellArguments;
158 } 157 }
159 158
160 String _windowsArgumentEscape(String argument) { 159 String _windowsArgumentEscape(String argument) {
161 var result = argument; 160 var result = argument;
162 if (argument.contains('\t') || argument.contains(' ')) { 161 if (argument.contains('\t') ||
162 argument.contains(' ') ||
163 argument.contains('"')) {
163 // Produce something that the C runtime on Windows will parse 164 // Produce something that the C runtime on Windows will parse
164 // back as this string. 165 // back as this string.
165 166
166 // Replace any number of '\' followed by '"' with 167 // Replace any number of '\' followed by '"' with
167 // twice as many '\' followed by '\"'. 168 // twice as many '\' followed by '\"'.
168 var backslash = '\\'.codeUnitAt(0); 169 var backslash = '\\'.codeUnitAt(0);
169 var sb = new StringBuffer(); 170 var sb = new StringBuffer();
170 var nextPos = 0; 171 var nextPos = 0;
171 var quotePos = argument.indexOf('"', nextPos); 172 var quotePos = argument.indexOf('"', nextPos);
172 while (quotePos != -1) { 173 while (quotePos != -1) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 const _ProcessResult(int this.pid, 381 const _ProcessResult(int this.pid,
381 int this.exitCode, 382 int this.exitCode,
382 String this.stdout, 383 String this.stdout,
383 String this.stderr); 384 String this.stderr);
384 385
385 final int pid; 386 final int pid;
386 final int exitCode; 387 final int exitCode;
387 final String stdout; 388 final String stdout;
388 final String stderr; 389 final String stderr;
389 } 390 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/process_shell_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698