]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libgo/go/cmd/go/internal/base/env.go
libgo: update to Go 1.13beta1 release
[thirdparty/gcc.git] / libgo / go / cmd / go / internal / base / env.go
index fcade9d84e228400547fe3d9532b42ad8b655d32..077295e0effcee5656192c2a39a0f4824be49f0b 100644 (file)
@@ -4,34 +4,12 @@
 
 package base
 
-import "strings"
-
-// EnvForDir returns a copy of the environment
-// suitable for running in the given directory.
-// The environment is the current process's environment
-// but with an updated $PWD, so that an os.Getwd in the
-// child will be faster.
+// EnvForDir returns a modified environment suitable for running in the given
+// directory.
+// The environment is the supplied base environment but with an updated $PWD, so
+// that an os.Getwd in the child will be faster.
 func EnvForDir(dir string, base []string) []string {
        // Internally we only use rooted paths, so dir is rooted.
        // Even if dir is not rooted, no harm done.
-       return MergeEnvLists([]string{"PWD=" + dir}, base)
-}
-
-// MergeEnvLists merges the two environment lists such that
-// variables with the same name in "in" replace those in "out".
-// This always returns a newly allocated slice.
-func MergeEnvLists(in, out []string) []string {
-       out = append([]string(nil), out...)
-NextVar:
-       for _, inkv := range in {
-               k := strings.SplitAfterN(inkv, "=", 2)[0]
-               for i, outkv := range out {
-                       if strings.HasPrefix(outkv, k) {
-                               out[i] = inkv
-                               continue NextVar
-                       }
-               }
-               out = append(out, inkv)
-       }
-       return out
+       return append(base, "PWD="+dir)
 }