(command: &str)
| 65 | } |
| 66 | |
| 67 | pub(super) fn is_shell_search_command(command: &str) -> bool { |
| 68 | // The quote/escape-aware parser shared with hooks.rs: quoted arguments |
| 69 | // stay single tokens, so a pattern like `grep "needle -r" file` can no |
| 70 | // longer leak a fake `-r` flag (the old split_whitespace misparse). |
| 71 | let tokens = shell_words(command); |
| 72 | let Some(first) = tokens.first() else { |
| 73 | return false; |
| 74 | }; |
| 75 | // Tolerate a leading subshell paren (`(grep -r foo)`), which the shell |
| 76 | // parser keeps attached to the first word. |
| 77 | let program = first.trim_start_matches('(').to_ascii_lowercase(); |
| 78 | match program.as_str() { |
| 79 | "rg" | "ripgrep" => true, |
| 80 | "grep" => tokens |
| 81 | .iter() |
| 82 | .skip(1) |
| 83 | .any(|token| is_recursive_grep_flag(token)), |
| 84 | _ => false, |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /// Classifies a shell command as a build/type-check invocation whose output the |
| 89 | /// model is about to parse by hand: `cargo check|build|clippy|test`, a bare |
nothing calls this directly
no test coverage detected