diff --git a/eval_test.go b/eval_test.go index e4a4993c..35257909 100644 --- a/eval_test.go +++ b/eval_test.go @@ -23,6 +23,24 @@ var gTests = []struct { nil, }, + { + "echo hello", + []string{"echo", "hello", "\n"}, + []Expr{&CallExpr{"echo", []string{"hello"}}}, + }, + + { + "echo hello world", + []string{"echo", "hello", "world", "\n"}, + []Expr{&CallExpr{"echo", []string{"hello", "world"}}}, + }, + + { + "echo 'hello world'", + []string{"echo", "hello world", "\n"}, + []Expr{&CallExpr{"echo", []string{"hello world"}}}, + }, + { "set hidden # trailing comments are allowed", []string{"set", "hidden", "\n"}, diff --git a/scan.go b/scan.go index 192c7a9b..242432d9 100644 --- a/scan.go +++ b/scan.go @@ -203,6 +203,15 @@ scan: s.next() } goto scan + case s.chr == '\'': + s.next() + beg := s.off + for !s.eof && s.chr != '\'' { + s.next() + } + s.typ = TokenIdent + s.tok = string(s.buf[beg:s.off]) + s.next() case s.chr == ':': s.typ = TokenColon s.tok = ":"