Skip to content

Commit

Permalink
WCOW:Use commandline in spec if populated
Browse files Browse the repository at this point in the history
Signed-off-by: John Howard <jhoward@microsoft.com>
  • Loading branch information
John Howard committed Feb 2, 2019
1 parent 71dd2bc commit a79ddd5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions cmd/runhcs/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,13 @@ var shimCommand = cli.Command{
Environment: environment,
User: spec.User.Username,
}
for i, arg := range spec.Args {
e := windows.EscapeArg(arg)
if i == 0 {
wpp.CommandLine = e
} else {
wpp.CommandLine += " " + e
}

if spec.CommandLine != "" {
wpp.CommandLine = spec.CommandLine
} else {
wpp.CommandLine = escapeArgs(spec.Args)
}

if spec.ConsoleSize != nil {
wpp.ConsoleSize = []int32{
int32(spec.ConsoleSize.Height),
Expand Down Expand Up @@ -321,3 +320,12 @@ var shimCommand = cli.Command{
return cli.NewExitError("", code)
},
}

// escapeArgs makes a Windows-style escaped command line from a set of arguments
func escapeArgs(args []string) string {
escapedArgs := make([]string, len(args))
for i, a := range args {
escapedArgs[i] = windows.EscapeArg(a)
}
return strings.Join(escapedArgs, " ")
}

0 comments on commit a79ddd5

Please sign in to comment.