Commit 3857822e authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: don't crash if arg is empty [GH-832]

parent 602ed10e
......@@ -2,6 +2,7 @@
BUG FIXES:
* core: Fix crash case if blank parameters are given to Packer. [GH-832]
* builders/docker: user variables work properly. [GH-777]
* builder/virtualbox,vmware: iso\_checksum is not required if the
checksum type is "none"
......
......@@ -221,7 +221,7 @@ func (e *coreEnvironment) Cli(args []string) (result int, err error) {
// Trim up to the command name
for i, v := range args {
if v[0] != '-' {
if len(v) > 0 && v[0] != '-' {
args = args[i:]
break
}
......
......@@ -198,10 +198,17 @@ func TestEnvironment_Cli_CallsRun(t *testing.T) {
func TestEnvironment_DefaultCli_Empty(t *testing.T) {
defaultEnv := testEnvironment()
// Test with no args
exitCode, _ := defaultEnv.Cli([]string{})
if exitCode != 1 {
t.Fatalf("bad: %d", exitCode)
}
// Test with only blank args
exitCode, _ = defaultEnv.Cli([]string{""})
if exitCode != 1 {
t.Fatalf("bad: %d", exitCode)
}
}
func TestEnvironment_DefaultCli_Help(t *testing.T) {
......
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