diff options
Diffstat (limited to 'pkg/commands/oscommands/cmd_obj_builder.go')
-rw-r--r-- | pkg/commands/oscommands/cmd_obj_builder.go | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/pkg/commands/oscommands/cmd_obj_builder.go b/pkg/commands/oscommands/cmd_obj_builder.go index 5929d6faf..a493ae651 100644 --- a/pkg/commands/oscommands/cmd_obj_builder.go +++ b/pkg/commands/oscommands/cmd_obj_builder.go @@ -21,9 +21,8 @@ type ICmdObjBuilder interface { } type CmdObjBuilder struct { - runner ICmdObjRunner - logCmdObj func(ICmdObj) - platform *Platform + runner ICmdObjRunner + platform *Platform } // poor man's version of explicitly saying that struct X implements interface Y @@ -76,8 +75,27 @@ func (self *CmdObjBuilder) CloneWithNewRunner(decorate func(ICmdObjRunner) ICmdO decoratedRunner := decorate(self.runner) return &CmdObjBuilder{ - runner: decoratedRunner, - logCmdObj: self.logCmdObj, - platform: self.platform, + runner: decoratedRunner, + platform: self.platform, } } + +func (self *CmdObjBuilder) Quote(message string) string { + var quote string + if self.platform.OS == "windows" { + quote = `\"` + message = strings.NewReplacer( + `"`, `"'"'"`, + `\"`, `\\"`, + ).Replace(message) + } else { + quote = `"` + message = strings.NewReplacer( + `\`, `\\`, + `"`, `\"`, + `$`, `\$`, + "`", "\\`", + ).Replace(message) + } + return quote + message + quote +} |