MCPcopy Index your code
hub / github.com/codeaashu/claude-code / skipEnvFlags

Function skipEnvFlags

src/tools/BashTool/pathValidation.ts:1244–1256  ·  view source on GitHub ↗

* Parse env's VAR=val and safe flags (-i/-0/-v/-u NAME). Returns argv index * of wrapped COMMAND, or -1 if unparseable/no wrapped cmd. Rejects -S (argv * splitter), -C/-P (altwd/altpath). Mirrors checkSemantics (ast.ts).

(a: readonly string[])

Source from the content-addressed store, hash-verified

1242 * splitter), -C/-P (altwd/altpath). Mirrors checkSemantics (ast.ts).
1243 */
1244function skipEnvFlags(a: readonly string[]): number {
1245 let i = 1
1246 while (i < a.length) {
1247 const arg = a[i]!
1248 if (arg.includes('=') && !arg.startsWith('-')) i++
1249 else if (arg === '-i' || arg === '-0' || arg === '-v') i++
1250 else if (arg === '-u' && a[i + 1]) i += 2
1251 else if (arg.startsWith('-'))
1252 return -1 // -S/-C/-P/unknown: fail closed
1253 else break
1254 }
1255 return i < a.length ? i : -1
1256}
1257
1258/**
1259 * Argv-level counterpart to stripSafeWrappers (bashPermissions.ts). Strips

Callers 1

stripWrappersFromArgvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected