From 77296e36457b070bc811a605c4c4bd6c36d972ae Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Thu, 27 Oct 2022 17:51:04 -0700 Subject: [PATCH] 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 --- src/cmd/go/internal/work/exec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.48.1