Closed snejus closed 2 months ago
Now regarding the test case with multiple comments - it actually evaluates to an invalid command if it's read literally (a comment between two flags does not make any sense).
Do you see any value in supporting this kind of thing? We could potentially pre-parse the command and ignore all comments altogether.
Now regarding the test case with multiple comments - it actually evaluates to an invalid command if it's read literally (a comment between two flags does not make any sense).
Do you see any value in supporting this kind of thing? We could potentially pre-parse the command and ignore all comments altogether.
Your assessment is correct. Allowing a cmd to be split over multiple lines (with escaping the line break) with comments on multiple lines is a little bit weird... but harmless and IMO potentially a nice thing to be able to do.
I think the root cause of the issue here is that although I made the AST implementation faithful to a subset of bash, when actually used in the cmd task it's configured to only treat ;
as a line terminator (not line breaks) and to later ignore lines with only whitespace or comments. However comments at the end of lines still end up terminating that line.
So to resolve this I just pushed a tweak to the cmd AST that allows tracking on the Line
object how it was terminated, so that we can implicitly merge lines that were only terminated with a comment. WDYT?
This looks good to me now. Thanks for working on it @snejus
Amazing, thanks for finishing this up!
Fixes #224