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)
| 11 | // embedded single quotes. The result is safe to embed in a shell command |
| 12 | // without risk of injection. |
| 13 | func ShellQuote(s string) string { |
| 14 | return "'" + strings.ReplaceAll(s, "'", "'\\''") + "'" |
| 15 | } |
no outgoing calls