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

Function HardQuotePowerShell

pkg/util/shellutil/shellquote.go:83–109  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

81}
82
83func HardQuotePowerShell(s string) string {
84 if s == "" {
85 return "\"\""
86 }
87
88 if !checkQuoteSize(s) {
89 return ""
90 }
91
92 buf := make([]byte, 0, len(s)+5)
93 buf = append(buf, '"')
94
95 for i := 0; i < len(s); i++ {
96 c := s[i]
97 // In PowerShell, backtick (`) is the escape character
98 switch c {
99 case '"', '`', '$':
100 buf = append(buf, '`')
101 case '\n':
102 buf = append(buf, '`', 'n') // PowerShell uses `n for newline
103 }
104 buf = append(buf, c)
105 }
106
107 buf = append(buf, '"')
108 return string(buf)
109}
110
111func SoftQuote(s string) string {
112 if s == "" {

Callers 2

InitRcFilesFunction · 0.85

Calls 1

checkQuoteSizeFunction · 0.85

Tested by

no test coverage detected