fix panic with only long flags or only one deprecatd

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
Victor Vieux 2014-03-05 19:45:57 +00:00
parent a5ba28e1f7
commit 7339ca8699
2 changed files with 4 additions and 4 deletions

View file

@ -290,13 +290,13 @@ type Flag struct {
func sortFlags(flags map[string]*Flag) []*Flag {
var list sort.StringSlice
for _, f := range flags {
fName := strings.TrimPrefix(f.Names[0], "#")
if len(f.Names) == 1 {
list = append(list, f.Names[0])
list = append(list, fName)
continue
}
found := false
fName := strings.TrimPrefix(strings.TrimPrefix(f.Names[0], "#"), "-")
for _, name := range list {
if name == fName {
found = true