MCPcopy Index your code
hub / github.com/jetify-com/devbox / String

Method String

nix/command.go:315–331  ·  view source on GitHub ↗

String returns the arguments as a shell command, quoting arguments with spaces.

()

Source from the content-addressed store, hash-verified

313// String returns the arguments as a shell command, quoting arguments with
314// spaces.
315func (a Args) String() string {
316 if len(a) == 0 {
317 return ""
318 }
319
320 sb := &strings.Builder{}
321 a.writeQuoted(sb, fmt.Sprint(a[0]))
322 if len(a) == 1 {
323 return sb.String()
324 }
325
326 for _, arg := range a[1:] {
327 sb.WriteByte(' ')
328 a.writeQuoted(sb, fmt.Sprint(arg))
329 }
330 return sb.String()
331}
332
333func (Args) writeQuoted(dst *strings.Builder, str string) {
334 needsQuote := strings.ContainsAny(str, ";\"'()$|&><` \t\r\n\\#{~*?[=")

Callers

nothing calls this directly

Calls 2

writeQuotedMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected