Browse code

Windows: Fixed escaping of command line arguments

This fixes some tests that were failing on windows

Signed-off-by: Darren Stahl <darst@microsoft.com>

Darren Stahl authored on 2015/09/24 07:12:23
Showing 2 changed files
... ...
@@ -12,6 +12,7 @@ import (
12 12
 	"path/filepath"
13 13
 	"strconv"
14 14
 	"strings"
15
+	"syscall"
15 16
 
16 17
 	"github.com/Sirupsen/logrus"
17 18
 	"github.com/docker/docker/daemon/execdriver"
... ...
@@ -258,7 +259,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd
258 258
 	createProcessParms.CommandLine = c.ProcessConfig.Entrypoint
259 259
 	for _, arg := range c.ProcessConfig.Arguments {
260 260
 		logrus.Debugln("appending ", arg)
261
-		createProcessParms.CommandLine += " " + arg
261
+		createProcessParms.CommandLine += " " + syscall.EscapeArg(arg)
262 262
 	}
263 263
 	logrus.Debugf("CommandLine: %s", createProcessParms.CommandLine)
264 264
 
... ...
@@ -450,12 +450,9 @@ func (s *DockerSuite) TestRunExitCode(c *check.C) {
450 450
 		exit int
451 451
 		err  error
452 452
 	)
453
-	if daemonPlatform == "windows" {
454
-		// FIXME Windows: Work out the bug in busybox why exit doesn't set the exit code.
455
-		_, exit, err = dockerCmdWithError("run", WindowsBaseImage, "cmd", "/s", "/c", "exit 72")
456
-	} else {
457
-		_, exit, err = dockerCmdWithError("run", "busybox", "/bin/sh", "-c", "exit 72")
458
-	}
453
+
454
+	_, exit, err = dockerCmdWithError("run", "busybox", "/bin/sh", "-c", "exit 72")
455
+
459 456
 	if err == nil {
460 457
 		c.Fatal("should not have a non nil error")
461 458
 	}