In a Python interactive session with the following setup:
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bashlex
Running the bashlex.parse function with the string declare -a CMDS=() produces the following output:
>>> bashlex.parse('declare -a CMDS=()')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python3.10/site-packages/bashlex/parser.py", line 610, in parse
parts = [p.parse()]
File "/home/user/.local/lib/python3.10/site-packages/bashlex/parser.py", line 691, in parse
tree = theparser.parse(lexer=self.tok, context=self)
File "/home/user/.local/lib/python3.10/site-packages/bashlex/yacc.py", line 537, in parse
tok = self.errorfunc(errtoken)
File "/home/user/.local/lib/python3.10/site-packages/bashlex/parser.py", line 548, in p_error
raise errors.ParsingError('unexpected token %r' % p.value,
bashlex.errors.ParsingError: unexpected token '(' (position 16)
Attempting to parse a script with array declaration fails upon encountering the opening set mark (ie: ().
The following
bashlex
information was provided bypip
:In a Python interactive session with the following setup:
Running the
bashlex.parse
function with the stringdeclare -a CMDS=()
produces the following output:When removing the round brackets it succeeds:
It's independent of the
declare
keyword:The error occurs when appending to the array as well:
Parsing parenthesis is not by itself the issue:
The lexer seems to recognize arrays as
WordNode
s:It just seems to have issues recognizing array sets when performing assignments.