bashlex icon indicating copy to clipboard operation
bashlex copied to clipboard

Multiple new lines at end of file

Open lacraig2 opened this issue 3 years ago • 3 comments

Working off of the base for PR #71 so this will be relevant after that PR is merged.

Multiple new lines at the end of an input triggers an "Unexpected EOF" error in line 546, in p_error.

Minimal example:

from bashlex import parse

parts = parse('cmd1\n\n')

This is not the case for a single newline at the end of the file (as of PR #71).

lacraig2 avatar Feb 26 '22 05:02 lacraig2

I'm a bit hesitant to merge it then. Could a fix alter the new logic significantly?

idank avatar Mar 03 '22 18:03 idank

That depends on how it's implemented. This is such a narrow case that I could see it being handled at preprocessing (i.e. before handing to the lexer).

lacraig2 avatar Mar 07 '22 16:03 lacraig2

Got it, that makes sense. I'm a bit cautious to steer from bash but if we think the direction we've taken with these changes is the right one then I'm good to merge.

idank avatar Mar 08 '22 14:03 idank