Only create a command line replacer once

Test: CI
Change-Id: Ibb9b822aea808c936fedc4c8fea7b7d787b101d5
This commit is contained in:
Liz Kammer
2023-02-09 14:28:36 -05:00
parent 690fbac200
commit f15a0797c0

View File

@@ -671,17 +671,18 @@ func expandTemplateContent(actionEntry action) string {
return replacer.Replace(actionEntry.TemplateContent)
}
func escapeCommandlineArgument(str string) string {
// \->\\, $->\$, `->\`, "->\", \n->\\n, '->'"'"'
replacer := strings.NewReplacer(
// \->\\, $->\$, `->\`, "->\", \n->\\n, '->'"'"'
var commandLineArgumentReplacer = strings.NewReplacer(
`\`, `\\`,
`$`, `\$`,
"`", "\\`",
`"`, `\"`,
"\n", "\\n",
`'`, `'"'"'`,
)
return replacer.Replace(str)
)
func escapeCommandlineArgument(str string) string {
return commandLineArgumentReplacer.Replace(str)
}
func (a action) isSymlinkAction() bool {