MCPcopy Create free account
hub / github.com/diillson/chatcli / ShellQuote

Function ShellQuote

utils/shell_escape.go:13–15  ·  view source on GitHub ↗

ShellQuote wraps a string in POSIX-compliant single quotes, escaping any embedded single quotes. The result is safe to embed in a shell command without risk of injection.

(s string)

Source from the content-addressed store, hash-verified

11// embedded single quotes. The result is safe to embed in a shell command
12// without risk of injection.
13func ShellQuote(s string) string {
14 return "'" + strings.ReplaceAll(s, "'", "'\\''") + "'"
15}

Callers 4

simulateCommandBlockMethod · 0.92
executeDirectCommandMethod · 0.92
executeInteractiveMethod · 0.92
TestShellQuoteFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestShellQuoteFunction · 0.68