Permalink
Browse files

Fix parser crash bug exposed by wild tests.

This was caused by the main_loop refactoring.

Example of file that was crashing, and now parses:

illumos-gate/usr/src/lib/libshell/common/tests/expand.sh
  • Loading branch information...
Andy Chu
Andy Chu committed Sep 8, 2018
1 parent 1400fe1 commit 0ba26bf0688f762a924d7b93f5c16df7838815d5
Showing with 6 additions and 5 deletions.
  1. +6 −5 osh/cmd_parse.py
View
@@ -1486,6 +1486,10 @@ def _ParseCommandLine(self):
b. If there's a sync_op, process it. Then look for a newline and
return. Otherwise, parse another AndOr.
"""
# NOTE: This is slightly different than END_LIST in _ParseCommandTerm, and
# unfortunately somewhat ad hoc.
END_LIST = (Id.Op_Newline, Id.Eof_Real, Id.Op_RParen)
children = []
done = False
while not done:
@@ -1498,13 +1502,10 @@ def _ParseCommandLine(self):
self._Next()
self._Peek()
if self.c_id in (Id.Op_Newline, Id.Eof_Real):
if self.c_id in END_LIST:
done = True
elif self.c_id == Id.Op_Newline:
done = True
elif self.c_id == Id.Eof_Real:
elif self.c_id in END_LIST:
done = True
else:

0 comments on commit 0ba26bf

Please sign in to comment.