Skip to content

Commit f0e904d

Browse files
committed
Merge pull request moby#16590 from Microsoft/10662-escapeargsfix
Windows: Flags to cmd are now sent as two separate arguments
2 parents ff92f45 + 5aa7c23 commit f0e904d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

builder/dispatchers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func run(ctx context.Context, b *builder, args []string, attributes map[string]b
315315
if runtime.GOOS != "windows" {
316316
args = append([]string{"/bin/sh", "-c"}, args...)
317317
} else {
318-
args = append([]string{"cmd", "/S /C"}, args...)
318+
args = append([]string{"cmd", "/S", "/C"}, args...)
319319
}
320320
}
321321

@@ -439,7 +439,7 @@ func cmd(ctx context.Context, b *builder, args []string, attributes map[string]b
439439
if runtime.GOOS != "windows" {
440440
cmdSlice = append([]string{"/bin/sh", "-c"}, cmdSlice...)
441441
} else {
442-
cmdSlice = append([]string{"cmd", "/S /C"}, cmdSlice...)
442+
cmdSlice = append([]string{"cmd", "/S", "/C"}, cmdSlice...)
443443
}
444444
}
445445

@@ -483,7 +483,7 @@ func entrypoint(ctx context.Context, b *builder, args []string, attributes map[s
483483
if runtime.GOOS != "windows" {
484484
b.Config.Entrypoint = stringutils.NewStrSlice("/bin/sh", "-c", parsed[0])
485485
} else {
486-
b.Config.Entrypoint = stringutils.NewStrSlice("cmd", "/S /C", parsed[0])
486+
b.Config.Entrypoint = stringutils.NewStrSlice("cmd", "/S", "/C", parsed[0])
487487
}
488488
}
489489

builder/internals.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (b *builder) commit(ctx context.Context, id string, autoCmd *stringutils.St
8989
if runtime.GOOS != "windows" {
9090
b.Config.Cmd = stringutils.NewStrSlice("/bin/sh", "-c", "#(nop) "+comment)
9191
} else {
92-
b.Config.Cmd = stringutils.NewStrSlice("cmd", "/S /C", "REM (nop) "+comment)
92+
b.Config.Cmd = stringutils.NewStrSlice("cmd", "/S", "/C", "REM (nop) "+comment)
9393
}
9494
defer func(cmd *stringutils.StrSlice) { b.Config.Cmd = cmd }(cmd)
9595

@@ -220,7 +220,7 @@ func (b *builder) runContextCommand(ctx context.Context, args []string, allowRem
220220
if runtime.GOOS != "windows" {
221221
b.Config.Cmd = stringutils.NewStrSlice("/bin/sh", "-c", fmt.Sprintf("#(nop) %s %s in %s", cmdName, srcHash, dest))
222222
} else {
223-
b.Config.Cmd = stringutils.NewStrSlice("cmd", "/S /C", fmt.Sprintf("REM (nop) %s %s in %s", cmdName, srcHash, dest))
223+
b.Config.Cmd = stringutils.NewStrSlice("cmd", "/S", "/C", fmt.Sprintf("REM (nop) %s %s in %s", cmdName, srcHash, dest))
224224
}
225225
defer func(cmd *stringutils.StrSlice) { b.Config.Cmd = cmd }(cmd)
226226

0 commit comments

Comments
 (0)