Skip to content

Commit

Permalink
syntax: improve unexpected token error for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza-Q authored Jun 16, 2020
1 parent 7ae7be3 commit 9d929f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion syntax/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ loop:
}
fallthrough
default:
p.curErr("a command can only contain words and redirects")
p.curErr("a command can only contain words and redirects; encountered %s", p.tok)
}
}
if len(ce.Assigns) == 0 && len(ce.Args) == 0 {
Expand Down
12 changes: 6 additions & 6 deletions syntax/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ var shellTests = []errorCase{
},
{
in: "a=b foo() { bar; }",
common: `1:8: a command can only contain words and redirects`,
common: `1:8: a command can only contain words and redirects; encountered (`,
},
{
in: "a=b if foo; then bar; fi",
Expand All @@ -493,7 +493,7 @@ var shellTests = []errorCase{
},
{
in: ">f foo() { bar; }",
common: `1:7: a command can only contain words and redirects`,
common: `1:7: a command can only contain words and redirects; encountered (`,
},
{
in: ">f if foo; then bar; fi",
Expand Down Expand Up @@ -643,7 +643,7 @@ var shellTests = []errorCase{
},
{
in: "echo foo(",
common: `1:9: a command can only contain words and redirects`,
common: `1:9: a command can only contain words and redirects; encountered (`,
},
{
in: "echo &&",
Expand Down Expand Up @@ -1176,7 +1176,7 @@ var shellTests = []errorCase{
},
{
in: "case i in 3) foo; 4) bar; esac",
common: `1:20: a command can only contain words and redirects`,
common: `1:20: a command can only contain words and redirects; encountered )`,
},
{
in: "case i in 3&) foo;",
Expand Down Expand Up @@ -1259,7 +1259,7 @@ var shellTests = []errorCase{
{
in: "]] )",
bsmk: `1:1: "]]" can only be used to close a test`,
posix: `1:4: a command can only contain words and redirects`,
posix: `1:4: a command can only contain words and redirects; encountered )`,
},
{
in: "((foo",
Expand Down Expand Up @@ -1690,7 +1690,7 @@ var shellTests = []errorCase{
},
{
in: "function foo() { bar; }",
posix: `1:13: a command can only contain words and redirects`,
posix: `1:13: a command can only contain words and redirects; encountered (`,
},
{
in: "echo <(",
Expand Down

0 comments on commit 9d929f2

Please sign in to comment.