MCPcopy Create free account
hub / github.com/AI45Lab/Code / contains_shell_control_operators

Function contains_shell_control_operators

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

Source from the content-addressed store, hash-verified

430
431#[cfg(windows)]
432fn contains_shell_control_operators(command: &str) -> bool {
433 let mut in_single = false;
434 let mut in_double = false;
435 let chars: Vec<char> = command.chars().collect();
436 let mut i = 0usize;
437 while i < chars.len() {
438 let ch = chars[i];
439 if ch == '\'' && !in_double {
440 in_single = !in_single;
441 } else if ch == '"' && !in_single {
442 in_double = !in_double;
443 } else if !in_single && !in_double {
444 if matches!(ch, '|' | ';' | '>' | '<') {
445 return true;
446 }
447 if ch == '&' && i + 1 < chars.len() && chars[i + 1] == '&' {
448 return true;
449 }
450 }
451 i += 1;
452 }
453 false
454}
455
456#[cfg(windows)]
457fn tokenize_windows_command(command: &str) -> Option<Vec<String>> {

Callers 1

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected