diff --git a/common/bootcommand/boot_command_ast.go b/common/bootcommand/boot_command_ast.go index 98a4afc81..f680345c4 100644 --- a/common/bootcommand/boot_command_ast.go +++ b/common/bootcommand/boot_command_ast.go @@ -75,11 +75,14 @@ func (s expressionSequence) Validate() (errs []error) { // GenerateExpressionSequence generates a sequence of expressions from the // given command. This is the primary entry point to the boot command parser. func GenerateExpressionSequence(command string) (expressionSequence, error) { + seq := expressionSequence{} + if command == "" { + return seq, nil + } got, err := ParseReader("", strings.NewReader(command)) if err != nil { return nil, err } - seq := expressionSequence{} for _, exp := range got.([]interface{}) { seq = append(seq, exp.(expression)) } diff --git a/common/bootcommand/boot_command_ast_test.go b/common/bootcommand/boot_command_ast_test.go index 9638da42f..d5ad21900 100644 --- a/common/bootcommand/boot_command_ast_test.go +++ b/common/bootcommand/boot_command_ast_test.go @@ -138,3 +138,9 @@ func Test_validation(t *testing.T) { } } } + +func Test_empty(t *testing.T) { + exp, err := GenerateExpressionSequence("") + assert.NoError(t, err, "should have parsed an empty input okay.") + assert.Len(t, exp, 0) +}