Skip to content

Commit 4576184

Browse files
committed
cmd/go/internal/envcmd: on unix pass script contents directly to sh -c
Instead of writing them to a file and executing that file. For #59998 Change-Id: I341786926762359f67dccb475295afbbb8ed1054 Reviewed-on: https://go-review.googlesource.com/c/go/+/493555 Run-TryBot: Michael Matloob <[email protected]> Reviewed-by: Michael Matloob <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent dd78bc0 commit 4576184

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/cmd/go/internal/envcmd/env_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,15 @@ func FuzzPrintEnvEscape(f *testing.F) {
6969
if runtime.GOOS == "windows" {
7070
scriptfilename = "script.bat"
7171
}
72-
scriptfile := filepath.Join(t.TempDir(), scriptfilename)
73-
if err := os.WriteFile(scriptfile, b.Bytes(), 0777); err != nil {
74-
t.Fatal(err)
75-
}
76-
t.Log(b.String())
7772
var cmd *exec.Cmd
7873
if runtime.GOOS == "windows" {
74+
scriptfile := filepath.Join(t.TempDir(), scriptfilename)
75+
if err := os.WriteFile(scriptfile, b.Bytes(), 0777); err != nil {
76+
t.Fatal(err)
77+
}
7978
cmd = testenv.Command(t, "cmd.exe", "/C", scriptfile)
8079
} else {
81-
cmd = testenv.Command(t, "sh", "-c", scriptfile)
80+
cmd = testenv.Command(t, "sh", "-c", b.String())
8281
}
8382
out, err := cmd.Output()
8483
t.Log(string(out))

0 commit comments

Comments
 (0)