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 <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh 2020-04-08 08:22:09 -04:00
parent f71e4d3d3e
commit 82bd7589e7
No known key found for this signature in database
GPG Key ID: A2DF901DABE2C028
1 changed files with 2 additions and 1 deletions

View File

@ -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 {