* 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. * Enumerates: --foreground/--preserve-status/--verbose (no value), * --kill-after/--signal (value, both =fused and space-separated), -v (no * val
(a: readonly string[])
| 631 | * feature('BASH_CLASSIFIER') evaluation in classifier tests. |
| 632 | */ |
| 633 | function skipTimeoutFlags(a: readonly string[]): number { |
| 634 | let i = 1 |
| 635 | while (i < a.length) { |
| 636 | const arg = a[i]! |
| 637 | const next = a[i + 1] |
| 638 | if ( |
| 639 | arg === '--foreground' || |
| 640 | arg === '--preserve-status' || |
| 641 | arg === '--verbose' |
| 642 | ) |
| 643 | i++ |
| 644 | else if (/^--(?:kill-after|signal)=[A-Za-z0-9_.+-]+$/.test(arg)) i++ |
| 645 | else if ( |
| 646 | (arg === '--kill-after' || arg === '--signal') && |
| 647 | next && |
| 648 | TIMEOUT_FLAG_VALUE_RE.test(next) |
| 649 | ) |
| 650 | i += 2 |
| 651 | else if (arg === '--') { |
| 652 | i++ |
| 653 | break |
| 654 | } // end-of-options marker |
| 655 | else if (arg.startsWith('--')) return -1 |
| 656 | else if (arg === '-v') i++ |
| 657 | else if ( |
| 658 | (arg === '-k' || arg === '-s') && |
| 659 | next && |
| 660 | TIMEOUT_FLAG_VALUE_RE.test(next) |
| 661 | ) |
| 662 | i += 2 |
| 663 | else if (/^-[ks][A-Za-z0-9_.+-]+$/.test(arg)) i++ |
| 664 | else if (arg.startsWith('-')) return -1 |
| 665 | else break |
| 666 | } |
| 667 | return i |
| 668 | } |
| 669 | |
| 670 | /** |
| 671 | * Argv-level counterpart to stripSafeWrappers. Strips the same wrapper |
no outgoing calls
no test coverage detected