Skip to content

Commit

Permalink
[arith] Make ? a right associative operator.
Browse files Browse the repository at this point in the history
Fixes bug #712.
  • Loading branch information
Andy Chu committed Apr 17, 2020
1 parent d688d3f commit d7834ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion osh/arith_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def MakeShellSpec():
spec.Left(9, tdop.LeftBinaryOp, [Id.Arith_DAmp])
spec.Left(7, tdop.LeftBinaryOp, [Id.Arith_DPipe])

spec.Left(5, LeftTernary, [Id.Arith_QMark])
spec.LeftRightAssoc(5, LeftTernary, [Id.Arith_QMark])

# Right associative: a = b = 2 is a = (b = 2)
spec.LeftRightAssoc(3, tdop.LeftAssign, [
Expand Down
7 changes: 7 additions & 0 deletions spec/arith.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -571,3 +571,10 @@ echo $(( a2 ))
0
0
## END

#### nested ternary (bug fix)
echo $((1?2?3:4:5))
## STDOUT:
3
## END

0 comments on commit d7834ef

Please sign in to comment.