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>
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)