MCPcopy Index your code
hub / github.com/coder/coder / firstNonFlagLiteral

Function firstNonFlagLiteral

coderd/util/shellparse/shellparse.go:100–109  ·  view source on GitHub ↗

firstNonFlagLiteral returns the literal value of the first word in ws that does not start with "-", or "" if none qualifies. Known limitation: no flag-arity knowledge. For programs whose global flags take a separate-word value ("git -C path verb", "kubectl -n ns verb", "docker --context X verb"), t

(ws []*syntax.Word)

Source from the content-addressed store, hash-verified

98// verb in those cases need per-program awareness; this function does
99// not provide it.
100func firstNonFlagLiteral(ws []*syntax.Word) string {
101 for _, w := range ws {
102 lit := wordLiteral(w)
103 if lit == "" || strings.HasPrefix(lit, "-") {
104 continue
105 }
106 return lit
107 }
108 return ""
109}

Callers 1

ParseFunction · 0.85

Calls 1

wordLiteralFunction · 0.85

Tested by

no test coverage detected