* 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[])
| 1242 | * splitter), -C/-P (altwd/altpath). Mirrors checkSemantics (ast.ts). |
| 1243 | */ |
| 1244 | function 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 |
no outgoing calls
no test coverage detected