diff --git a/builtin/bins/dkron-executor-shell/shell.go b/builtin/bins/dkron-executor-shell/shell.go index e3978c0cc..3d4da4bef 100644 --- a/builtin/bins/dkron-executor-shell/shell.go +++ b/builtin/bins/dkron-executor-shell/shell.go @@ -165,6 +165,9 @@ func buildCmd(command string, useShell bool, env []string, cwd string) (cmd *exe if err != nil { return nil, err } + if len(args) == 0 { + return nil, errors.New("shell: Command missing") + } cmd = exec.Command(args[0], args[1:]...) } if env != nil { diff --git a/builtin/bins/dkron-executor-shell/shell_test.go b/builtin/bins/dkron-executor-shell/shell_test.go index f93520408..039077564 100644 --- a/builtin/bins/dkron-executor-shell/shell_test.go +++ b/builtin/bins/dkron-executor-shell/shell_test.go @@ -7,6 +7,10 @@ import ( "github.com/stretchr/testify/assert" ) +func Test_buildCmdInvalidInput(t *testing.T) { + assert.NotPanics(t, func() { buildCmd("", false, []string{}, "") }) +} + func Test_buildCmd(t *testing.T) { // test shell command