MCPcopy
hub / github.com/wavetermdev/waveterm / HardQuoteFish

Function HardQuoteFish

pkg/util/shellutil/shellquote.go:54–81  ·  view source on GitHub ↗

does not encode newlines or backticks

(s string)

Source from the content-addressed store, hash-verified

52
53// does not encode newlines or backticks
54func HardQuoteFish(s string) string {
55 if s == "" {
56 return "\"\""
57 }
58
59 if safePattern.MatchString(s) {
60 return s
61 }
62
63 if !checkQuoteSize(s) {
64 return ""
65 }
66
67 buf := make([]byte, 0, len(s)+5)
68 buf = append(buf, '"')
69
70 for i := 0; i < len(s); i++ {
71 switch s[i] {
72 case '"', '\\', '$':
73 buf = append(buf, '\\', s[i])
74 default:
75 buf = append(buf, s[i])
76 }
77 }
78
79 buf = append(buf, '"')
80 return string(buf)
81}
82
83func HardQuotePowerShell(s string) string {
84 if s == "" {

Callers 2

StartLocalShellProcFunction · 0.92
encodeEnvVarsForFishFunction · 0.85

Calls 1

checkQuoteSizeFunction · 0.85

Tested by

no test coverage detected