From: Michael Matloob Date: Fri, 28 Oct 2022 00:51:04 +0000 (-0700) Subject: cmd/go: don't substitute '$WORK' for work directory in -x heredocs X-Git-Tag: go1.20rc1~512 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=77296e36457b070bc811a605c4c4bd6c36d972ae;p=gostls13.git cmd/go: don't substitute '$WORK' for work directory in -x heredocs When writing the set of commands excuted for go build -x, $WORK is substituted for the work directory in all the commnands. But this includes the cat < Run-TryBot: Michael Matloob Reviewed-by: Bryan Mills Reviewed-by: Michael Matloob --- diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 79d5615f89..11f6c7a498 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -2061,7 +2061,7 @@ func (b *Builder) fmtcmd(dir string, format string, args ...any) string { cmd = "cd " + dir + "\n" + cmd } } - if b.WorkDir != "" { + if b.WorkDir != "" && !strings.HasPrefix(cmd, "cat ") { cmd = strings.ReplaceAll(cmd, b.WorkDir, "$WORK") escaped := strconv.Quote(b.WorkDir) escaped = escaped[1 : len(escaped)-1] // strip quote characters