summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bazel/aquery.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/bazel/aquery.go b/bazel/aquery.go
index 6a5e05413..6af472a8d 100644
--- a/bazel/aquery.go
+++ b/bazel/aquery.go
@@ -671,17 +671,18 @@ func expandTemplateContent(actionEntry action) string {
return replacer.Replace(actionEntry.TemplateContent)
}
+// \->\\, $->\$, `->\`, "->\", \n->\\n, '->'"'"'
+var commandLineArgumentReplacer = strings.NewReplacer(
+ `\`, `\\`,
+ `$`, `\$`,
+ "`", "\\`",
+ `"`, `\"`,
+ "\n", "\\n",
+ `'`, `'"'"'`,
+)
+
func escapeCommandlineArgument(str string) string {
- // \->\\, $->\$, `->\`, "->\", \n->\\n, '->'"'"'
- replacer := strings.NewReplacer(
- `\`, `\\`,
- `$`, `\$`,
- "`", "\\`",
- `"`, `\"`,
- "\n", "\\n",
- `'`, `'"'"'`,
- )
- return replacer.Replace(str)
+ return commandLineArgumentReplacer.Replace(str)
}
func (a action) isSymlinkAction() bool {