Skip to content

Commit

Permalink
Fix shell executor crashing on missing command (#948)
Browse files Browse the repository at this point in the history
  • Loading branch information
yvanoers authored May 6, 2021
1 parent fcb3af4 commit 162e8db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/bins/dkron-executor-shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions builtin/bins/dkron-executor-shell/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 162e8db

Please sign in to comment.