Commit 08863626 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #2229 from mitchellh/b-shell-quote

provisioner/shell: escape single quotes [GH-2067]
parents 53cf5070 c549fce8
...@@ -145,6 +145,9 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { ...@@ -145,6 +145,9 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
errs = packer.MultiErrorAppend(errs, errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Environment variable not in format 'key=value': %s", kv)) fmt.Errorf("Environment variable not in format 'key=value': %s", kv))
} else { } else {
// Replace single quotes so they parse
vs[1] = strings.Replace(vs[1], "'", `'"'"'`, -1)
// Single quote env var values // Single quote env var values
p.config.Vars[idx] = fmt.Sprintf("%s='%s'", vs[0], vs[1]) p.config.Vars[idx] = fmt.Sprintf("%s='%s'", vs[0], vs[1])
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment