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

Method quoteAliasValue

internal/devbox/shell.go:385–396  ·  view source on GitHub ↗

quoteAliasValue single-quotes an alias value so it is passed verbatim to the shell's `alias` builtin, escaping any embedded quotes for the current shell.

(value string)

Source from the content-addressed store, hash-verified

383// quoteAliasValue single-quotes an alias value so it is passed verbatim to the
384// shell's `alias` builtin, escaping any embedded quotes for the current shell.
385func (s *DevboxShell) quoteAliasValue(value string) string {
386 if s.name == shFish {
387 // Inside fish single quotes, only \\ and \' are escape sequences.
388 value = strings.ReplaceAll(value, `\`, `\\`)
389 value = strings.ReplaceAll(value, `'`, `\'`)
390 return "'" + value + "'"
391 }
392 // POSIX shells (bash/zsh/ksh): close the quote, emit an escaped quote,
393 // then reopen, i.e. ' -> '\''.
394 value = strings.ReplaceAll(value, `'`, `'\''`)
395 return "'" + value + "'"
396}
397
398// setupShellStartupFiles creates initialization files for the shell by sourcing the user's originals.
399// We do this instead of linking or copying, so that we can set correct ZDOTDIR when sourcing

Callers 1

aliasLinesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected