diff options
author | Brent Baude <bbaude@redhat.com> | 2020-03-23 11:56:46 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-03-24 07:28:55 -0500 |
commit | 2d4fa996ef86d803442f96112ab9ee341d26215a (patch) | |
tree | 0aa0ce07265b0fd6d7581764070d6bfe825a6724 /cmd/podmanV2/root.go | |
parent | 3dbf2cb5aff67f82e486cd95aca170e44b8fc75a (diff) | |
download | podman-2d4fa996ef86d803442f96112ab9ee341d26215a.tar.gz podman-2d4fa996ef86d803442f96112ab9ee341d26215a.tar.bz2 podman-2d4fa996ef86d803442f96112ab9ee341d26215a.zip |
podmanv2 exit code
add ability to set and get exit code.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podmanV2/root.go')
-rw-r--r-- | cmd/podmanV2/root.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cmd/podmanV2/root.go b/cmd/podmanV2/root.go index b0dd7643f..2becd126d 100644 --- a/cmd/podmanV2/root.go +++ b/cmd/podmanV2/root.go @@ -6,6 +6,7 @@ import ( "path" "github.com/containers/libpod/cmd/podmanV2/registry" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/version" "github.com/spf13/cobra" ) @@ -31,7 +32,14 @@ func init() { func Execute() { if err := rootCmd.Execute(); err != nil { - fmt.Println(err) - os.Exit(1) + fmt.Fprintln(os.Stderr, "Error:", err.Error()) + } else if registry.GetExitCode() == define.ExecErrorCodeGeneric { + // The exitCode modified from define.ExecErrorCodeGeneric, + // indicates an application + // running inside of a container failed, as opposed to the + // podman command failed. Must exit with that exit code + // otherwise command exited correctly. + registry.SetExitCode(0) } + os.Exit(registry.GetExitCode()) } |