mirror of
https://github.com/golang/go
synced 2024-11-19 11:04:47 -07:00
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 <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
d0ed8d6ea1
commit
2a7e19e038
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user