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

Function skipStdbufFlags

src/tools/BashTool/pathValidation.ts:1225–1237  ·  view source on GitHub ↗

* Parse stdbuf's flags (-i/-o/-e in fused/space-separated/long-= forms). * Returns argv index of wrapped COMMAND, or -1 if unparseable or no flags * consumed (stdbuf without flags is inert). Mirrors checkSemantics (ast.ts).

(a: readonly string[])

Source from the content-addressed store, hash-verified

1223 * consumed (stdbuf without flags is inert). Mirrors checkSemantics (ast.ts).
1224 */
1225function skipStdbufFlags(a: readonly string[]): number {
1226 let i = 1
1227 while (i < a.length) {
1228 const arg = a[i]!
1229 if (/^-[ioe]$/.test(arg) && a[i + 1]) i += 2
1230 else if (/^-[ioe]./.test(arg)) i++
1231 else if (/^--(input|output|error)=/.test(arg)) i++
1232 else if (arg.startsWith('-'))
1233 return -1 // unknown flag: fail closed
1234 else break
1235 }
1236 return i > 1 && i < a.length ? i : -1
1237}
1238
1239/**
1240 * Parse env's VAR=val and safe flags (-i/-0/-v/-u NAME). Returns argv index

Callers 1

stripWrappersFromArgvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected