dockerfile: set default shell based on OS

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
v0.8
Tonis Tiigi 2020-10-23 15:29:53 -07:00
parent ecf070a027
commit 63856b6a36
4 changed files with 9 additions and 15 deletions

View File

@ -1353,7 +1353,7 @@ func withShell(img Image, args []string) []string {
if len(img.Config.Shell) > 0 {
shell = append([]string{}, img.Config.Shell...)
} else {
shell = defaultShell()
shell = defaultShell(img.OS)
}
return append(shell, strings.Join(args, " "))
}

View File

@ -0,0 +1,8 @@
package dockerfile2llb
func defaultShell(os string) []string {
if os == "windows" {
return []string{"cmd", "/S", "/C"}
}
return []string{"/bin/sh", "-c"}
}

View File

@ -1,7 +0,0 @@
// +build !windows
package dockerfile2llb
func defaultShell() []string {
return []string{"/bin/sh", "-c"}
}

View File

@ -1,7 +0,0 @@
// +build windows
package dockerfile2llb
func defaultShell() []string {
return []string{"cmd", "/S", "/C"}
}