diff --git a/ssh.go b/ssh.go index d2cad3f..10e6853 100644 --- a/ssh.go +++ b/ssh.go @@ -306,13 +306,13 @@ func (c *SSHClient) buildComand(task *Task) string { switch inter { case "bash", "sh", "zsh", "ksh", "tcsh": - return fmt.Sprintf("/usr/bin/env %s %s -c \"set -x\n%s\"", c.env, i, strings.Replace(task.Run, `"`, `\"`, -1)) + return fmt.Sprintf("/usr/bin/env %s %s -c 'set -x\n%s'", c.env, i, strings.Replace(task.Run, `'`, `\'`, -1)) // TODO: add support for python already called via env case "python", "python3": - return fmt.Sprintf("/usr/bin/env %s %s -c \"%s\"", c.env, i, strings.Replace(task.Run, `"`, `\"`, -1)) + return fmt.Sprintf("/usr/bin/env %s %s -c '%s'", c.env, i, strings.Replace(task.Run, `'`, `\'`, -1)) default: - return fmt.Sprintf("/usr/bin/env %s bash -c \"set -x\n%s\"", c.env, strings.Replace(task.Run, `"`, `\"`, -1)) + return fmt.Sprintf("/usr/bin/env %s bash -c 'set -x\n%s'", c.env, strings.Replace(task.Run, `'`, `\'`, -1)) } } diff --git a/sup.go b/sup.go index 6ee7ed0..0c45e3a 100644 --- a/sup.go +++ b/sup.go @@ -36,7 +36,7 @@ func (sup *Stackup) Run(network *Network, commands ...*Command) error { // `export FOO="bar"; export BAR="baz";`. env := `` for _, v := range append(sup.conf.Env, network.Env...) { - env += v.String() + " " + env += v.QuotedString() + " " } // Create clients for every host (either SSH or Localhost). diff --git a/supfile.go b/supfile.go index 6031ba4..d633f30 100644 --- a/supfile.go +++ b/supfile.go @@ -64,6 +64,10 @@ func (e EnvVar) String() string { return e.Key + `=` + e.Value } +func (e EnvVar) QuotedString() string { + return e.Key + `="` + e.Value + `"` +} + // AsExport returns the environment variable as a bash export statement func (e EnvVar) AsExport() string { return `export ` + e.Key + `="` + e.Value + `";`