Skip to content

Commit

Permalink
Merge pull request #12 from linux-immutability-tools/fix/non-zero-exit
Browse files Browse the repository at this point in the history
fix: exit with non-zero returncode when failing
  • Loading branch information
axtloss authored Jan 12, 2024
2 parents 816f07d + 1aead15 commit 2ae15e7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/spf13/cobra"
"os"
)

var rootCmd = &cobra.Command{
Expand All @@ -13,6 +14,10 @@ func init() {
rootCmd.AddCommand(NewVerifyCommand())
}

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

0 comments on commit 2ae15e7

Please sign in to comment.