mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
a9533b0426
Hook into an existing SSH Agent. This allows us to pull keys already authenticated by the agent and write to the agent ourselves. --------- Co-authored-by: Evan Simkowitz <esimkowitz@users.noreply.github.com>
29 lines
447 B
Go
29 lines
447 B
Go
package trimquotes
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
func TrimQuotes(s string) (string, bool) {
|
|
if len(s) > 2 && s[0] == '"' {
|
|
trimmed, err := strconv.Unquote(s)
|
|
if err != nil {
|
|
return s, false
|
|
}
|
|
return trimmed, true
|
|
}
|
|
return s, false
|
|
}
|
|
|
|
func TryTrimQuotes(s string) string {
|
|
trimmed, _ := TrimQuotes(s)
|
|
return trimmed
|
|
}
|
|
|
|
func ReplaceQuotes(s string, shouldReplace bool) string {
|
|
if shouldReplace {
|
|
return strconv.Quote(s)
|
|
}
|
|
return s
|
|
}
|