From 40ed10cc32fe6dbf18d13a43d42a1a9bed0df902 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 31 Oct 2013 18:39:44 -0700 Subject: [PATCH 1/2] fix inspect when it returns nothing valid --- commands.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index 0e06f47947..05c8b6bb04 100644 --- a/commands.go +++ b/commands.go @@ -667,9 +667,11 @@ func (cli *DockerCli) CmdInspect(args ...string) error { } indented.WriteString(",") } - // Remove trailling ',' - indented.Truncate(indented.Len() - 1) + if indented.Len() > 0 { + // Remove trailling ',' + indented.Truncate(indented.Len() - 1) + } fmt.Fprintf(cli.out, "[") if _, err := io.Copy(cli.out, indented); err != nil { return err From a89a98e59432109d99c08b43f670df7429145172 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 31 Oct 2013 18:44:16 -0700 Subject: [PATCH 2/2] fix inspect error message --- commands.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index 05c8b6bb04..20f5855e16 100644 --- a/commands.go +++ b/commands.go @@ -654,7 +654,11 @@ func (cli *DockerCli) CmdInspect(args ...string) error { if err != nil { obj, _, err = cli.call("GET", "/images/"+name+"/json", nil) if err != nil { - fmt.Fprintf(cli.err, "No such image or container: %s\n", name) + if strings.Contains(err.Error(), "No such") { + fmt.Fprintf(cli.err, "Error: No such image or container: %s\n", name) + } else { + fmt.Fprintf(cli.err, "%s", err) + } status = 1 continue } @@ -669,7 +673,7 @@ func (cli *DockerCli) CmdInspect(args ...string) error { } if indented.Len() > 0 { - // Remove trailling ',' + // Remove trailing ',' indented.Truncate(indented.Len() - 1) } fmt.Fprintf(cli.out, "[")