(s string)
| 81 | } |
| 82 | |
| 83 | func 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 | |
| 111 | func SoftQuote(s string) string { |
| 112 | if s == "" { |
no test coverage detected