1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

only os.Exits on error

This commit is contained in:
Victor Vieux 2013-09-09 21:26:35 +00:00
parent 9b088ada7e
commit 46a1cd69a9
3 changed files with 15 additions and 1 deletions

View file

@ -1479,7 +1479,9 @@ func (cli *DockerCli) CmdRun(args ...string) error {
if err != nil {
return err
}
os.Exit(status)
if status != 0 {
return &utils.StatusError{status}
}
}
return nil

View file

@ -75,6 +75,9 @@ func main() {
}
protoAddrParts := strings.SplitN(flHosts[0], "://", 2)
if err := docker.ParseCommands(protoAddrParts[0], protoAddrParts[1], flag.Args()...); err != nil {
if sterr, ok := err.(*utils.StatusError); ok {
os.Exit(sterr.Status)
}
log.Fatal(err)
os.Exit(-1)
}

View file

@ -1012,3 +1012,12 @@ func (graph *DependencyGraph) GenerateTraversalMap() ([][]string, error) {
}
return result, nil
}
// An StatusError reports an unsuccessful exit by a command.
type StatusError struct {
Status int
}
func (e *StatusError) Error() string {
return fmt.Sprintf("Status: %d", e.Status)
}