add whitespace escaping for backslash
This commit is contained in:
1 parent
87434d3fe6
commit
bfd33f8437
2 files changed
+36
-2
No files matched your search
@@ -41,6 +41,30 @@ var gTests = []struct {
|
||||
[]Expr{&CallExpr{"echo", []string{"hello world"}}},
|
||||
},
|
||||
|
||||
{
|
||||
`echo hello\ world`,
|
||||
[]string{"echo", "hello world", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello world"}}},
|
||||
},
|
||||
|
||||
{
|
||||
`echo hello\ world`,
|
||||
[]string{"echo", "hello\tworld", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello\tworld"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"echo hello\\\nworld",
|
||||
[]string{"echo", "hello\nworld", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello\nworld"}}},
|
||||
},
|
||||
|
||||
{
|
||||
`echo hello\aworld`,
|
||||
[]string{"echo", "helloworld", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"helloworld"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"set hidden # trailing comments are allowed",
|
||||
[]string{"set", "hidden", "\n"},
|
||||
|
||||
@@ -236,13 +236,23 @@ scan:
|
||||
s.cmd = true
|
||||
s.next()
|
||||
default:
|
||||
beg := s.off
|
||||
var buf []byte
|
||||
for !s.eof && !isSpace(s.chr) && s.chr != ';' && s.chr != '#' {
|
||||
if s.chr == '\\' {
|
||||
s.next()
|
||||
if isSpace(s.chr) {
|
||||
buf = append(buf, s.chr)
|
||||
s.next()
|
||||
} else {
|
||||
s.next()
|
||||
}
|
||||
}
|
||||
buf = append(buf, s.chr)
|
||||
s.next()
|
||||
}
|
||||
|
||||
s.typ = TokenIdent
|
||||
s.tok = string(s.buf[beg:s.off])
|
||||
s.tok = string(buf)
|
||||
s.sem = true
|
||||
|
||||
if s.tok == "push" {
|
||||
|
||||
Reference in new issue
Block a user