Previous fix used %q which incorrectly go-escaped things. For example:

```
RUN echoo A \& B	C
```
would result in the user seeing:
```
INFO[0000] The command '/bin/sh -c echoo A \\& B\tC' returned a non-zero code: 127
```
Note the double-\ and the \t instead of a tab character

The testcase had to double escape things due to logrus getting in the way
but I'm going to fix that in another PR because its a change to the UX.

Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
Doug Davis 2015-05-09 09:22:30 -07:00
Родитель 7699cee247
Коммит 006c066b6c
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -623,7 +623,7 @@ func (b *Builder) run(c *daemon.Container) error {
// Wait for it to finish // Wait for it to finish
if ret, _ := c.WaitStop(-1 * time.Second); ret != 0 { if ret, _ := c.WaitStop(-1 * time.Second); ret != 0 {
return &jsonmessage.JSONError{ return &jsonmessage.JSONError{
Message: fmt.Sprintf("The command %q returned a non-zero code: %d", b.Config.Cmd.ToString(), ret), Message: fmt.Sprintf("The command '%s' returned a non-zero code: %d", b.Config.Cmd.ToString(), ret),
Code: ret, Code: ret,
} }
} }

Просмотреть файл

@ -5416,12 +5416,12 @@ func (s *DockerSuite) TestBuildRUNErrMsg(c *check.C) {
name := "testbuildbadrunerrmsg" name := "testbuildbadrunerrmsg"
_, out, err := buildImageWithOut(name, ` _, out, err := buildImageWithOut(name, `
FROM busybox FROM busybox
RUN badEXE a1 a2`, false) RUN badEXE a1 \& a2 a3`, false) // tab between a2 and a3
if err == nil { if err == nil {
c.Fatal("Should have failed to build") c.Fatal("Should have failed to build")
} }
exp := `The command \"/bin/sh -c badEXE a1 a2\" returned a non-zero code: 127"` exp := "The command '/bin/sh -c badEXE a1 \\\\& a2\\ta3' returned a non-zero code: 127"
if !strings.Contains(out, exp) { if !strings.Contains(out, exp) {
c.Fatalf("RUN doesn't have the correct output:\nGot:%s\nExpected:%s", out, exp) c.Fatalf("RUN doesn't have the correct output:\nGot:%s\nExpected:%s", out, exp)
} }