@@ -279,11 +279,24 @@ impl Command { |
|
|
|
|
|
|
|
|
279 |
279 |
None |
|
|
|
|
|
|
280 |
280 |
}; |
|
|
|
|
|
|
281 |
281 |
let program = resolve_exe(&self.program, | |
env::var_os("PATH"), child_paths)?; |
|
|
|
|
|
282 |
|
-// Case insensitive "ends_with" of UTF-16 encoded ".bat" or ".cmd" |
|
|
|
|
|
|
283 |
|
-let is_batch_file = matches!( |
|
|
|
|
|
|
284 |
|
- program.len().checked_sub(5).and_then(|i |
program.get(i..)), |
|
|
|
|
|
285 |
|
-Some([46, 98 | 66, 97 |
65, 116 |
84, 0] |
[46, 99 |
67, 109 |
77, 100 |
68, 0]) |
286 |
|
-); |
|
|
|
|
|
|
|
282 |
+let has_bat_extension = |program: &[u16] |
{ |
|
|
|
|
|
|
283 |
+matches!( |
|
|
|
|
|
|
|
284 |
+// Case insensitive "ends_with" of UTF-16 encoded ".bat" or ".cmd" |
|
|
|
|
|
|
|
285 |
+ program.len().checked_sub(4).and_then(|i |
program.get(i..)), |
|
|
|
|
|
|
286 |
+Some([46, 98 | 66, 97 |
65, 116 |
84] |
[46, 99 |
67, 109 |
77, 100 |
68]) |
|
287 |
+) |
|
|
|
|
|
|
|
288 |
+}; |
|
|
|
|
|
|
|
289 |
+let is_batch_file = if path::is_verbatim(&program) { |
|
|
|
|
|
|
|
290 |
+has_bat_extension(&program[..program.len() - 1]) |
|
|
|
|
|
|
|
291 |
+} else { |
|
|
|
|
|
|
|
292 |
+super::fill_utf16_buf( |
|
|
|
|
|
|
|
293 |
+ |buffer, size |
unsafe { |
|
|
|
|
|
|
294 |
+// resolve the path so we can test the final file name. |
|
|
|
|
|
|
|
295 |
+ c::GetFullPathNameW(program.as_ptr(), size, buffer, ptr::null_mut()) |
|
|
|
|
|
|
|
296 |
+}, |
|
|
|
|
|
|
|
297 |
+ |program |
has_bat_extension(program), |
|
|
|
|
|
|
298 |
+)? |
|
|
|
|
|
|
|
299 |
+}; |
|
|
|
|
|
|
287 |
300 |
let (program, mut cmd_str) = if is_batch_file { |
|
|
|
|
|
|
288 |
301 |
( |
|
|
|
|
|
|
289 |
302 |
command_prompt()?, |
|
|
|
|
|
|