From 56979a19740d7b3b44ef27a032a46c55e6c518d7 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Wed, 21 Jun 2017 16:11:47 -0700 Subject: [PATCH] Revert "Universally provide POSIX semantics for the `shell` provisioner." This reverts commit 1ba7f9cc20d5947c7c562f799cebcf3b5601fcce. --- provisioner/shell/provisioner.go | 2 +- website/source/docs/provisioners/shell.html.md | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 3ed30b681..5e9c587a1 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -101,7 +101,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } if p.config.ExecuteCommand == "" { - p.config.ExecuteCommand = "chmod +x {{.Path}}; env {{.Vars}} {{.Path}}" + p.config.ExecuteCommand = "chmod +x {{.Path}}; {{.Vars}} {{.Path}}" } if p.config.ExpectDisconnect == nil { diff --git a/website/source/docs/provisioners/shell.html.md b/website/source/docs/provisioners/shell.html.md index 23e7a0d6e..efa99aa37 100644 --- a/website/source/docs/provisioners/shell.html.md +++ b/website/source/docs/provisioners/shell.html.md @@ -66,7 +66,7 @@ Optional parameters: as well, which are covered in the section below. - `execute_command` (string) - The command to use to execute the script. By - default this is `chmod +x {{ .Path }}; env {{ .Vars }} {{ .Path }}`. The value + default this is `chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}`. The value of this is treated as [configuration template](/docs/templates/engine.html). There are two available variables: `Path`, which is the path to the script to run, and @@ -126,15 +126,18 @@ is being piped in with the value of `packer`. By setting the `execute_command` to this, your script(s) can run with root privileges without worrying about password prompts. -### `execute_command` Example +### FreeBSD Example -The following contrived example shows how to pass environment variables and -change the permissions of the script to be executed: +FreeBSD's default shell is `tcsh`, which deviates from POSIX semantics. In order +for packer to pass environment variables you will need to change the +`execute_command` to: ``` text -chmod +x {{ .Path }}; chmod 0700 {{ .Path}}; env {{ .Vars }} {{ .Path }} +chmod +x {{ .Path }}; env {{ .Vars }} {{ .Path }} ``` +Note the addition of `env` before `{{ .Vars }}`. + ## Default Environmental Variables In addition to being able to specify custom environmental variables using the