Skip to content
Myr

Split the doubled and plain backslash cases in the quoting test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

escapeArg only doubles a backslash that precedes a quote or ends the argument, the same rule as syscall.EscapeArg, and @ is not a cmd metacharacter so it is not caret-escaped. The Windows expectations here still asked for both. Checked by round-tripping each entry through cmd.exe into a program's argv: all ten come back byte for byte.

authored by Cyrus · committed by Junegunn Choi · parent d4b6ba7 · Browse files · 1 file+6 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−6 removed

  • other:+6 added−6 removed

1 file+6 added−6 removed

modified:src/terminal_test.go+6 added-6 removed
249 unmodified lines
250 }251}252253func TestQuoteEntry(t *testing.T) {254 type quotes struct{ E, O, SQ, DQ, BS string } // standalone escape, outer, single and double quotes, backslash255 unixStyle := quotes{``, `'`, `'\''`, `"`, `\`}256 windowsStyle := quotes{`^`, `^"`, `'`, `\^"`, `\\`}254 type quotes struct{ E, O, SQ, DQ, BS, PB string } // standalone escape, outer, single and double quotes, doubled and plain backslash255 unixStyle := quotes{``, `'`, `'\''`, `"`, `\`, `\`}256 windowsStyle := quotes{`^`, `^"`, `'`, `\^"`, `\\`, `\`}257 var effectiveStyle quotes258 exec := util.NewExecutor("")259260 if util.IsWindows() {
18 unmodified lines
279 `<`: `{{.O}}{{.E}}<{{.O}}`,280 `>`: `{{.O}}{{.E}}>{{.O}}`,281 `(`: `{{.O}}{{.E}}({{.O}}`,282 `)`: `{{.O}}{{.E}}){{.O}}`,283 `@`: `{{.O}}{{.E}}@{{.O}}`,283 `@`: `{{.O}}@{{.O}}`,284 `^`: `{{.O}}{{.E}}^{{.O}}`,285 `%`: `{{.O}}{{.E}}%{{.O}}`,286 `!`: `{{.O}}{{.E}}!{{.O}}`,287 `%USERPROFILE%`: `{{.O}}{{.E}}%USERPROFILE{{.E}}%{{.O}}`,288 `C:\Program Files (x86)\`: `{{.O}}C:{{.BS}}Program Files {{.E}}(x86{{.E}}){{.BS}}{{.O}}`,289 `"C:\Program Files"`: `{{.O}}{{.DQ}}C:{{.BS}}Program Files{{.DQ}}{{.O}}`,288 `C:\Program Files (x86)\`: `{{.O}}C:{{.PB}}Program Files {{.E}}(x86{{.E}}){{.BS}}{{.O}}`,289 `"C:\Program Files"`: `{{.O}}{{.DQ}}C:{{.PB}}Program Files{{.DQ}}{{.O}}`,290 }291292 for input, expected := range tests {293 escaped := exec.QuoteEntry(input)
630 unmodified lines