aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/base/env.go
diff options
context:
space:
mode:
authorChressie Himpel <chressie@google.com>2022-04-27 20:09:28 +0200
committerChressie Himpel <chressie@google.com>2022-04-27 20:09:28 +0200
commitec7f5165ddc680efbac18dc15b4905844d9e8db9 (patch)
treeeacc43345e3d6f0adfda16bfcf66e7e5096a85b9 /src/cmd/go/internal/base/env.go
parentca6fd39cf6498d4507fc7cdaced55620c283a503 (diff)
parentf0ee7fda636408b4f04ca3f3b11788f662c90610 (diff)
downloadgo-ec7f5165ddc680efbac18dc15b4905844d9e8db9.tar.gz
go-ec7f5165ddc680efbac18dc15b4905844d9e8db9.zip
[dev.boringcrypto] all: merge master into dev.boringcrypto
Change-Id: Ic5f71c04f08c03319c043f35be501875adb0a3b0
Diffstat (limited to 'src/cmd/go/internal/base/env.go')
-rw-r--r--src/cmd/go/internal/base/env.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cmd/go/internal/base/env.go b/src/cmd/go/internal/base/env.go
index 5f2665d2367..2f47300f2ec 100644
--- a/src/cmd/go/internal/base/env.go
+++ b/src/cmd/go/internal/base/env.go
@@ -4,12 +4,20 @@
package base
+import (
+ "fmt"
+ "path/filepath"
+)
+
// AppendPWD returns the result of appending PWD=dir to the environment base.
//
// The resulting environment makes os.Getwd more efficient for a subprocess
// running in dir.
func AppendPWD(base []string, dir string) []string {
- // Internally we only use absolute paths, so dir is absolute.
- // Even if dir is not absolute, no harm done.
+ // POSIX requires PWD to be absolute.
+ // Internally we only use absolute paths, so dir should already be absolute.
+ if !filepath.IsAbs(dir) {
+ panic(fmt.Sprintf("AppendPWD with relative path %q", dir))
+ }
return append(base, "PWD="+dir)
}