diff options
-rw-r--r-- | bitbake/lib/bb/codeparser.py | 5 | ||||
-rw-r--r-- | bitbake/lib/bb/pysh/pyshyacc.py | 17 |
2 files changed, 13 insertions, 9 deletions
diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py index ddd1b97dcb..3f8ac1d5f6 100644 --- a/bitbake/lib/bb/codeparser.py +++ b/bitbake/lib/bb/codeparser.py @@ -368,8 +368,9 @@ class ShellParser(): def _parse_shell(self, value): try: tokens, _ = pyshyacc.parse(value, eof=True, debug=False) - except pyshlex.NeedMore: - raise sherrors.ShellSyntaxError("Unexpected EOF") + except Exception: + bb.error('Error during parse shell code, the last 5 lines are:\n%s' % '\n'.join(value.split('\n')[-5:])) + raise self.process_tokens(tokens) diff --git a/bitbake/lib/bb/pysh/pyshyacc.py b/bitbake/lib/bb/pysh/pyshyacc.py index ba4cefdcb8..de565dc9af 100644 --- a/bitbake/lib/bb/pysh/pyshyacc.py +++ b/bitbake/lib/bb/pysh/pyshyacc.py @@ -636,13 +636,16 @@ def p_empty(p): def p_error(p): msg = [] w = msg.append - w('%r\n' % p) - w('followed by:\n') - for i in range(5): - n = yacc.token() - if not n: - break - w(' %r\n' % n) + if p: + w('%r\n' % p) + w('followed by:\n') + for i in range(5): + n = yacc.token() + if not n: + break + w(' %r\n' % n) + else: + w('Unexpected EOF') raise sherrors.ShellSyntaxError(''.join(msg)) # Build the parser |