github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/builder/dockerfile/dispatchers_unix.go (about)

     1  // +build !windows
     2  
     3  package dockerfile // import "github.com/docker/docker/builder/dockerfile"
     4  
     5  import (
     6  	"errors"
     7  	"os"
     8  	"path/filepath"
     9  
    10  	"github.com/docker/docker/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  }