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

Fixed a bug which caused dockerd to crash when it received a call without arguments

This commit is contained in:
Solomon Hykes 2013-02-12 09:10:47 -08:00
parent d0b6f7ef3b
commit 178e126a07

View file

@ -27,6 +27,9 @@ type CmdMethod func(Service, io.ReadCloser, io.Writer, ...string) error
func call(service Service, stdin io.ReadCloser, stdout io.Writer, args ...string) error { func call(service Service, stdin io.ReadCloser, stdout io.Writer, args ...string) error {
if len(args) == 0 {
args = []string{"help"}
}
flags := flag.NewFlagSet("main", flag.ContinueOnError) flags := flag.NewFlagSet("main", flag.ContinueOnError)
flags.SetOutput(stdout) flags.SetOutput(stdout)
flags.Usage = func() { stdout.Write([]byte(service.Help())) } flags.Usage = func() { stdout.Write([]byte(service.Help())) }
@ -40,7 +43,7 @@ func call(service Service, stdin io.ReadCloser, stdout io.Writer, args ...string
} }
method := getMethod(service, cmd) method := getMethod(service, cmd)
if method != nil { if method != nil {
return method(stdin, stdout, args[1:]...) return method(stdin, stdout, flags.Args()[1:]...)
} }
return errors.New("No such command: " + cmd) return errors.New("No such command: " + cmd)
} }