Skip to content

Commit

Permalink
Use exit code from command if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Nov 1, 2021
1 parent 76e2720 commit cce6980
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ func Execute(code Block) Result {

// update status code
if err != nil {
exitCode = 1
if cmd.ProcessState != nil {
exitCode = cmd.ProcessState.ExitCode()
} else {
exitCode = 1 // non-zero
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/code/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func main() {
},
expected: code.Result{
Out: "exit status 127",
ExitCode: 1,
ExitCode: 127,
},
},
{
Expand Down

0 comments on commit cce6980

Please sign in to comment.