MCPcopy
hub / github.com/coder/mux / getGrepCommandTokenIndex

Function getGrepCommandTokenIndex

src/node/services/tools/bash.ts:222–245  ·  view source on GitHub ↗
(tokens: string[])

Source from the content-addressed store, hash-verified

220}
221
222function getGrepCommandTokenIndex(tokens: string[]): number | null {
223 if (tokens.length === 0) {
224 return null;
225 }
226
227 if (isGrepToken(tokens[0])) {
228 return 0;
229 }
230
231 if (tokens[0] === "command" && tokens[1] && isGrepToken(tokens[1])) {
232 return 1;
233 }
234
235 // Handle common patterns like: sudo grep file, sudo -n grep file, sudo -u user grep file
236 if (tokens[0] === "sudo") {
237 for (let i = 1; i < tokens.length && i < 8; i++) {
238 if (isGrepToken(tokens[i])) {
239 return i;
240 }
241 }
242 }
243
244 return null;
245}
246
247function parseSearchCommandArgs(
248 command: SearchCommand,

Callers 1

detectGrepFileDumpFunction · 0.85

Calls 1

isGrepTokenFunction · 0.85

Tested by

no test coverage detected