Compare commits

...

2 Commits

Author SHA1 Message Date
lilleman 57b2d182c7 Name both quotings when a shell splits a template
Tests / vet + fmt + tests (pull_request) Successful in 1m25s
Tests / Gitea release from CHANGELOG.md (pull_request) Has been skipped
2026-09-18 20:39:54 +02:00
lilleman fb5a5ff38f Test that a split template names both quotings 2026-09-18 20:39:08 +02:00
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -491,7 +491,7 @@ func run(args []string, stdout, stderr io.Writer) int {
func templateSplit(paths []string) string { func templateSplit(paths []string) string {
for _, p := range paths { for _, p := range paths {
if strings.Contains(p, "{") { if strings.Contains(p, "{") {
return `; a template's spaces split the argument, so wrap the whole argument in "…"` return `; a template's spaces split the argument, so wrap the whole argument in "…", or in '…' where it carries double quotes`
} }
} }
return "" return ""
+8
View File
@@ -223,6 +223,14 @@ func TestRunMisuse(t *testing.T) {
t.Errorf("run(%v) stdout = %q, want nothing", args, out) t.Errorf("run(%v) stdout = %q, want nothing", args, out)
} }
} }
// A template a shell split names both quotings, since which one cures it turns
// on whether the argument carries a double-quoted JSON.
_, _, errb := runOut("{date(1990-01-01,2010-12-31,", "January", "2,", "2006)}")
for _, want := range []string{`wrap the whole argument in "…"`, `or in '…'`} {
if !strings.Contains(errb, want) {
t.Errorf("a split template stderr = %q, want it to name %s", errb, want)
}
}
} }
func TestRunMultipleDataPaths(t *testing.T) { func TestRunMultipleDataPaths(t *testing.T) {