From 82bd7589e7a6c930c6ddfce43d956304cb3e3f8b Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 8 Apr 2020 08:22:09 -0400 Subject: Set exit codes on errors. podmanV2 run fedora /etc Should exit with 126 podmanV2 run fedora /etc/foobar Should exit with 127 podmanv2 run --fobar fedora echo hello Should exit with 125 podmanv2 run fedora bash -c "exit 100" Should exit with 100 Signed-off-by: Daniel J Walsh --- cmd/podmanV2/containers/run.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/podmanV2/containers/run.go b/cmd/podmanV2/containers/run.go index 5c0069afc..f839c358d 100644 --- a/cmd/podmanV2/containers/run.go +++ b/cmd/podmanV2/containers/run.go @@ -109,13 +109,14 @@ func run(cmd *cobra.Command, args []string) error { } runOpts.Spec = s report, err := registry.ContainerEngine().ContainerRun(registry.GetContext(), runOpts) + // report.ExitCode is set by ContainerRun even it it returns an error + registry.SetExitCode(report.ExitCode) if err != nil { return err } if cliVals.Detach { fmt.Println(report.Id) } - registry.SetExitCode(report.ExitCode) if runRmi { _, err := registry.ImageEngine().Delete(registry.GetContext(), []string{report.Id}, entities.ImageDeleteOptions{}) if err != nil { -- cgit v1.2.3-54-g00ecf