mirror of
https://github.com/rkt/rkt.git
synced 2026-03-13 09:40:21 +08:00
Merge pull request #3926 from clchiou/escape-percent-args
stage1: escape '%' in command lines as well as '$'
This commit is contained in:
@@ -55,6 +55,7 @@ func execEscape(i int, str string) string {
|
||||
|
||||
if i > 0 { // These are escaped only after the first argument
|
||||
escapeMap[`$`] = `$`
|
||||
escapeMap[`%`] = `%`
|
||||
}
|
||||
|
||||
escArg := fmt.Sprintf("%q", str)
|
||||
|
||||
@@ -55,6 +55,9 @@ func TestQuoteExec(t *testing.T) {
|
||||
}, {
|
||||
input: []string{`$path$`, `$argument`},
|
||||
output: `"$path$" "$$argument"`,
|
||||
}, {
|
||||
input: []string{`%path%`, `%argument`},
|
||||
output: `"%path%" "%%argument"`,
|
||||
}, {
|
||||
input: []string{`path`, `Args\nwith\nnewlines`},
|
||||
output: `"path" "Args\\nwith\\nnewlines"`,
|
||||
|
||||
Reference in New Issue
Block a user