MCPcopy Create free account
hub / github.com/Noumena-Network/code / skipTimeoutFlags

Function skipTimeoutFlags

src/tools/BashTool/bashPermissions.ts:634–669  ·  view source on GitHub ↗

* 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[])

Source from the content-addressed store, hash-verified

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

Callers 1

stripWrappersFromArgvFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected