From: Ian Lance Taylor Date: Fri, 4 May 2018 22:43:50 +0000 (-0700) Subject: cmd/go: quote parentheses when outputting command X-Git-Tag: go1.11beta1~525 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2a7e19e0383430d75dcef9637c0c6dcaf64127d5;p=gostls13.git cmd/go: quote parentheses when outputting command A gccgo command line can contain parentheses, for -( and -). Quote them when outputting a command line, so that `go build -x` output is suitable for use as shell input. Change-Id: I43194b87bf048e583c222b19ca4bcdcb1deca97a Reviewed-on: https://go-review.googlesource.com/111635 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index fd607bfbd3..7379b886cc 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -1580,7 +1580,9 @@ func joinUnambiguously(a []string) string { buf.WriteByte(' ') } q := strconv.Quote(s) - if s == "" || strings.Contains(s, " ") || len(q) > len(s)+2 { + // A gccgo command line can contain -( and -). + // Make sure we quote them since they are special to the shell. + if s == "" || strings.ContainsAny(s, " ()") || len(q) > len(s)+2 { buf.WriteString(q) } else { buf.WriteString(s)