rootless, rm: fix retcode when the container is not found

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2019-03-18 22:57:36 +01:00
parent 3f96d3617b
commit 4ab7462add

View File

@ -108,6 +108,7 @@ func rmCmd(c *cliconfig.RmValues) error {
c.Latest = false
c.InputArgs = []string{rootless.Argument()}
} else {
exitCode = 0
var containers []*libpod.Container
if c.All {
containers, err = runtime.GetContainers()
@ -121,6 +122,10 @@ func rmCmd(c *cliconfig.RmValues) error {
for _, c := range c.InputArgs {
container, err = runtime.LookupContainer(c)
if err != nil {
if errors.Cause(err) == libpod.ErrNoSuchCtr {
exitCode = 1
continue
}
return err
}
containers = append(containers, container)
@ -136,7 +141,7 @@ func rmCmd(c *cliconfig.RmValues) error {
os.Exit(ret)
}
}
os.Exit(0)
os.Exit(exitCode)
}
}