MCPcopy Index your code
hub / github.com/AI45Lab/Code / tokenize_windows_command

Function tokenize_windows_command

core/src/tools/builtin/bash.rs:457–491  ·  view source on GitHub ↗
(command: &str)

Source from the content-addressed store, hash-verified

455
456#[cfg(windows)]
457fn tokenize_windows_command(command: &str) -> Option<Vec<String>> {
458 let mut tokens = Vec::new();
459 let mut current = String::new();
460 let mut chars = command.chars().peekable();
461 let mut in_single = false;
462 let mut in_double = false;
463
464 while let Some(ch) = chars.next() {
465 match ch {
466 '\'' if !in_double => in_single = !in_single,
467 '"' if !in_single => in_double = !in_double,
468 '\\' if in_double => {
469 if let Some(next) = chars.next() {
470 current.push(next);
471 }
472 }
473 ch if ch.is_whitespace() && !in_single && !in_double => {
474 if !current.is_empty() {
475 tokens.push(std::mem::take(&mut current));
476 }
477 }
478 other => current.push(other),
479 }
480 }
481
482 if in_single || in_double {
483 return None;
484 }
485
486 if !current.is_empty() {
487 tokens.push(current);
488 }
489
490 Some(tokens)
491}
492
493#[cfg(windows)]
494fn parse_simple_windows_http_command(command: &str) -> Option<SimpleWindowsHttpCommand> {

Callers 1

Calls 2

nextMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected