File tree 4 files changed +20
-1
lines changed 4 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -402,7 +402,7 @@ func (g *Generator) exec(words []string) {
402
402
"GOFILE=" + g .file ,
403
403
"GOPACKAGE=" + g .pkg ,
404
404
}
405
- cmd .Env = mergeEnvLists (env , os . Environ () )
405
+ cmd .Env = mergeEnvLists (env , origEnv )
406
406
err := cmd .Run ()
407
407
if err != nil {
408
408
g .errorf ("running %q: %s" , words [0 ], err )
Original file line number Diff line number Diff line change @@ -2229,3 +2229,18 @@ func TestGoInstallShadowedGOPATH(t *testing.T) {
2229
2229
tg .runFail ("install" )
2230
2230
tg .grepStderr ("no install location for.*gopath2.src.test: hidden by .*gopath1.src.test" , "missing error" )
2231
2231
}
2232
+
2233
+ func TestIssue11709 (t * testing.T ) {
2234
+ tg := testgo (t )
2235
+ defer tg .cleanup ()
2236
+ tg .tempFile ("run.go" , `
2237
+ package main
2238
+ import "os"
2239
+ func main() {
2240
+ if os.Getenv("TERM") != "" {
2241
+ os.Exit(1)
2242
+ }
2243
+ }` )
2244
+ tg .unsetenv ("TERM" )
2245
+ tg .run ("run" , tg .path ("run.go" ))
2246
+ }
Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ func setExitStatus(n int) {
112
112
exitMu .Unlock ()
113
113
}
114
114
115
+ var origEnv []string
116
+
115
117
func main () {
116
118
_ = go11tag
117
119
flag .Usage = usage
@@ -159,6 +161,7 @@ func main() {
159
161
// the same default computation of these as we do,
160
162
// but in practice there might be skew
161
163
// This makes sure we all agree.
164
+ origEnv = os .Environ ()
162
165
for _ , env := range mkEnv () {
163
166
if os .Getenv (env .name ) != env .value {
164
167
os .Setenv (env .name , env .value )
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ func runStdin(cmdline []string) {
137
137
cmd .Stdin = os .Stdin
138
138
cmd .Stdout = os .Stdout
139
139
cmd .Stderr = os .Stderr
140
+ cmd .Env = origEnv
140
141
startSigHandlers ()
141
142
if err := cmd .Run (); err != nil {
142
143
errorf ("%v" , err )
You can’t perform that action at this time.
0 commit comments