aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/format/format.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/format/format.go b/lib/format/format.go
index ad0b778c..7466cfd5 100644
--- a/lib/format/format.go
+++ b/lib/format/format.go
@@ -93,6 +93,23 @@ func TruncateHead(s string, w int, head string) string {
return head + s[pos:]
}
+func ShellQuote(args []string) string {
+ quoted := make([]string, len(args))
+
+ for i, arg := range args {
+ if strings.ContainsAny(arg, " '\"|&!#$;[](){}<>*\n\t") {
+ if strings.ContainsAny(arg, "!\"$") {
+ arg = "'" + arg + "'"
+ } else {
+ arg = "\"" + arg + "\""
+ }
+ }
+ quoted[i] = arg
+ }
+
+ return strings.Join(quoted, " ")
+}
+
type Ctx struct {
FromAddress string
AccountName string