dispatchers_unix.go 762 B

1234567891011121314151617181920212223242526272829
  1. // +build !windows
  2. package dockerfile
  3. import (
  4. "errors"
  5. "os"
  6. "path/filepath"
  7. )
  8. // normalizeWorkdir normalizes a user requested working directory in a
  9. // platform semantically consistent way.
  10. func normalizeWorkdir(_ string, current string, requested string) (string, error) {
  11. if requested == "" {
  12. return "", errors.New("cannot normalize nothing")
  13. }
  14. current = filepath.FromSlash(current)
  15. requested = filepath.FromSlash(requested)
  16. if !filepath.IsAbs(requested) {
  17. return filepath.Join(string(os.PathSeparator), current, requested), nil
  18. }
  19. return requested, nil
  20. }
  21. // equalEnvKeys compare two strings and returns true if they are equal. On
  22. // Windows this comparison is case insensitive.
  23. func equalEnvKeys(from, to string) bool {
  24. return from == to
  25. }