packer: don't crash if arg is empty [GH-832]
This commit is contained in:
parent
602ed10e89
commit
3857822ef2
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue