diff --git a/eval_test.go b/eval_test.go index cc6668a..94c0e3e 100644 --- a/eval_test.go +++ b/eval_test.go @@ -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"}, diff --git a/scan.go b/scan.go index b9c5726..6159876 100644 --- a/scan.go +++ b/scan.go @@ -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 {