Adjust shell quoting
Alpine 3.19 Success Details

This commit is contained in:
Přemysl Eric Janouch 2024-04-17 01:44:57 +02:00
parent b594ff78b2
commit 4a23c47a92
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 2 additions and 2 deletions

View File

@ -102,7 +102,7 @@ var shellFuncs = ttemplate.FuncMap{
"quote": func(word string) string {
// History expansion is annoying, don't let it cut us.
if strings.IndexRune(word, '!') >= 0 {
return "'" + strings.ReplaceAll(word, "'", `'"'"'`) + "'"
return "'" + strings.ReplaceAll(word, "'", `'\''`) + "'"
}
const special = "$`\"\\"

View File

@ -12,7 +12,7 @@ func TestTemplateQuote(t *testing.T) {
for _, test := range []struct {
input, output string
}{
{`!!`, `'!!'`},
{`!!'!$`, `'!!'\''!$'`},
{``, `""`},
{`${var}`, `"\${var}"`},
{"`cat`", "\"\\`cat\\`\""},