Skip to content

Commit 2ae15e7

Browse files
authored
Merge pull request #12 from linux-immutability-tools/fix/non-zero-exit
fix: exit with non-zero returncode when failing
2 parents 816f07d + 1aead15 commit 2ae15e7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/root.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"github.com/spf13/cobra"
5+
"os"
56
)
67

78
var rootCmd = &cobra.Command{
@@ -13,6 +14,10 @@ func init() {
1314
rootCmd.AddCommand(NewVerifyCommand())
1415
}
1516

16-
func Execute() error {
17-
return rootCmd.Execute()
17+
func Execute() {
18+
// cobra does not exit with a non-zero return code when failing
19+
// solution from https://github.com/spf13/cobra/issues/221
20+
if err := rootCmd.Execute(); err != nil {
21+
os.Exit(1)
22+
}
1823
}

0 commit comments

Comments
 (0)