Skip to content

Commit

Permalink
syntax: ensure that |& errors on posix via a test
Browse files Browse the repository at this point in the history
We were sort of testing it indirectly. Add an obvious test and comment,
since the code threw me off for a moment.
  • Loading branch information
mvdan committed Dec 21, 2018
1 parent 329a2c6 commit e18078e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions syntax/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,8 @@ func (p *Parser) gotStmtPipe(s *Stmt) *Stmt {
switch p.tok {
case orAnd:
if p.lang == LangMirBSDKorn {
// No need to check for LangPOSIX, as on that language
// we parse |& as two tokens.
break
}
fallthrough
Expand Down
4 changes: 4 additions & 0 deletions syntax/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,10 @@ var shellTests = []errorCase{
in: "|& a",
bsmk: `1:1: |& is not a valid start for a statement`,
},
{
in: "foo |& bar",
posix: `1:5: | must be followed by a statement`,
},
{
in: "let",
bsmk: `1:1: "let" must be followed by an expression`,
Expand Down

0 comments on commit e18078e

Please sign in to comment.