* Parse timeout's GNU flags (long + short, fused + space-separated) and * return the argv index of the DURATION token, or -1 if flags are unparseable.
(a: readonly string[])
| 1181 | * return the argv index of the DURATION token, or -1 if flags are unparseable. |
| 1182 | */ |
| 1183 | function skipTimeoutFlags(a: readonly string[]): number { |
| 1184 | let i = 1 |
| 1185 | while (i < a.length) { |
| 1186 | const arg = a[i]! |
| 1187 | const next = a[i + 1] |
| 1188 | if ( |
| 1189 | arg === '--foreground' || |
| 1190 | arg === '--preserve-status' || |
| 1191 | arg === '--verbose' |
| 1192 | ) |
| 1193 | i++ |
| 1194 | else if (/^--(?:kill-after|signal)=[A-Za-z0-9_.+-]+$/.test(arg)) i++ |
| 1195 | else if ( |
| 1196 | (arg === '--kill-after' || arg === '--signal') && |
| 1197 | next && |
| 1198 | TIMEOUT_FLAG_VALUE_RE.test(next) |
| 1199 | ) |
| 1200 | i += 2 |
| 1201 | else if (arg === '--') { |
| 1202 | i++ |
| 1203 | break |
| 1204 | } // end-of-options marker |
| 1205 | else if (arg.startsWith('--')) return -1 |
| 1206 | else if (arg === '-v') i++ |
| 1207 | else if ( |
| 1208 | (arg === '-k' || arg === '-s') && |
| 1209 | next && |
| 1210 | TIMEOUT_FLAG_VALUE_RE.test(next) |
| 1211 | ) |
| 1212 | i += 2 |
| 1213 | else if (/^-[ks][A-Za-z0-9_.+-]+$/.test(arg)) i++ |
| 1214 | else if (arg.startsWith('-')) return -1 |
| 1215 | else break |
| 1216 | } |
| 1217 | return i |
| 1218 | } |
| 1219 | |
| 1220 | /** |
| 1221 | * Parse stdbuf's flags (-i/-o/-e in fused/space-separated/long-= forms). |
no outgoing calls
no test coverage detected