github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/builder/dockerfile/dispatchers_unix.go (about) 1 // +build !windows 2 3 package dockerfile // import "github.com/demonoid81/moby/builder/dockerfile" 4 5 import ( 6 "errors" 7 "os" 8 "path/filepath" 9 10 "github.com/demonoid81/moby/api/types/container" 11 "github.com/moby/buildkit/frontend/dockerfile/instructions" 12 ) 13 14 // normalizeWorkdir normalizes a user requested working directory in a 15 // platform semantically consistent way. 16 func normalizeWorkdir(_ string, current string, requested string) (string, error) { 17 if requested == "" { 18 return "", errors.New("cannot normalize nothing") 19 } 20 current = filepath.FromSlash(current) 21 requested = filepath.FromSlash(requested) 22 if !filepath.IsAbs(requested) { 23 return filepath.Join(string(os.PathSeparator), current, requested), nil 24 } 25 return requested, nil 26 } 27 28 // resolveCmdLine takes a command line arg set and optionally prepends a platform-specific 29 // shell in front of it. 30 func resolveCmdLine(cmd instructions.ShellDependantCmdLine, runConfig *container.Config, os, _, _ string) ([]string, bool) { 31 result := cmd.CmdLine 32 if cmd.PrependShell && result != nil { 33 result = append(getShell(runConfig, os), result...) 34 } 35 return result, false 36 }