commandlinebuilder.go 1003 B

123456789101112131415161718192021222324252627282930313233343536
  1. //+build windows
  2. package windows
  3. import (
  4. "errors"
  5. "syscall"
  6. "github.com/Sirupsen/logrus"
  7. "github.com/docker/docker/daemon/execdriver"
  8. )
  9. // createCommandLine creates a command line from the Entrypoint and args
  10. // of the ProcessConfig. It escapes the arguments if they are not already
  11. // escaped
  12. func createCommandLine(processConfig *execdriver.ProcessConfig, alreadyEscaped bool) (commandLine string, err error) {
  13. // While this should get caught earlier, just in case, validate that we
  14. // have something to run.
  15. if processConfig.Entrypoint == "" {
  16. return "", errors.New("No entrypoint specified")
  17. }
  18. // Build the command line of the process
  19. commandLine = processConfig.Entrypoint
  20. logrus.Debugf("Entrypoint: %s", processConfig.Entrypoint)
  21. for _, arg := range processConfig.Arguments {
  22. logrus.Debugf("appending %s", arg)
  23. if !alreadyEscaped {
  24. arg = syscall.EscapeArg(arg)
  25. }
  26. commandLine += " " + arg
  27. }
  28. logrus.Debugf("commandLine: %s", commandLine)
  29. return commandLine, nil
  30. }