allow double backslash escape without quotes

Related #142
This commit is contained in:
Gokcehan 2019-08-05 22:24:12 +03:00
parent 488bf9f6b6
commit 6982ffe4cf
2 changed files with 7 additions and 1 deletions

View File

@ -101,6 +101,12 @@ var gEvalTests = []struct {
[]expr{&callExpr{"echo", []string{"hello\nworld"}, 1}},
},
{
`echo hello\\world`,
[]string{"echo", `hello\world`, "\n"},
[]expr{&callExpr{"echo", []string{`hello\world`}, 1}},
},
{
`echo hello\zworld`,
[]string{"echo", "helloworld", "\n"},

View File

@ -293,7 +293,7 @@ scan:
for !s.eof && !isSpace(s.chr) && s.chr != ';' && s.chr != '#' {
if s.chr == '\\' {
s.next()
if isSpace(s.chr) {
if isSpace(s.chr) || s.chr == '\\' {
buf = append(buf, s.chr)
s.next()
} else {