diff --git a/common/shell-local/run.go b/common/shell-local/run.go index ea8043737..a16573e7a 100644 --- a/common/shell-local/run.go +++ b/common/shell-local/run.go @@ -15,8 +15,9 @@ import ( ) type ExecuteCommandTemplate struct { - Vars string - Script string + Vars string + Script string + Command string } func Run(ui packer.Ui, config *Config) (bool, error) { @@ -106,8 +107,9 @@ func createInlineScriptFile(config *Config) (string, error) { // the host OS func createInterpolatedCommands(config *Config, script string, flattenedEnvVars string) ([]string, error) { config.Ctx.Data = &ExecuteCommandTemplate{ - Vars: flattenedEnvVars, - Script: script, + Vars: flattenedEnvVars, + Script: script, + Command: script, } interpolatedCmds := make([]string, len(config.ExecuteCommand)) diff --git a/website/source/docs/provisioners/shell-local.html.md b/website/source/docs/provisioners/shell-local.html.md index f40c4e9f0..eae9cf2ff 100644 --- a/website/source/docs/provisioners/shell-local.html.md +++ b/website/source/docs/provisioners/shell-local.html.md @@ -78,18 +78,21 @@ Optional parameters: This is treated as a [template engine](/docs/templates/engine.html). There are two available variables: `Script`, which is the path to the script to run, and `Vars`, which is the list of `environment_vars`, if configured - If you choose to set this option, make sure that the first element in the - array is the shell program you want to use (for example, "sh" or - "/usr/local/bin/zsh" or even "powershell.exe" although anything other than - a flavor of the shell command language is not explicitly supported and may - be broken by assumptions made within Packer), and a later element in the - array must be `{{.Script}}`. - For backwards compatability, {{.Command}} is also available to use in - `execute_command` but it is decoded the same way as {{.Script}}. We - recommend using {{.Script}} for the sake of clarity, as even when you set - only a single `command` to run, Packer writes it to a temporary file and - then runs it as a script. + If you choose to set this option, make sure that the first element in the + array is the shell program you want to use (for example, "sh"), and a later + element in the array must be `{{.Script}}`. + + This option provides you a great deal of flexibility. You may choose to + provide your own shell program, for example "/usr/local/bin/zsh" or even + "powershell.exe". However, with great power comes great responsibility - + these commands are not officially supported and things like environment + variables may not work if you use a different shell than the default. + + For backwards compatability, you may also use {{.Command}}, but it is + decoded the same way as {{.Script}}. We recommend using {{.Script}} for the + sake of clarity, as even when you set only a single `command` to run, + Packer writes it to a temporary file and then runs it as a script. - `inline_shebang` (string) - The [shebang](http://en.wikipedia.org/wiki/Shebang_%28Unix%29) value to use when