Open mmhat opened 4 years ago
I could implement that if we agree on a solution.
Hmm right now parse(prettyPrint(ast)) == ast for all possible trees (or at least that's the goal) but adding a newline would break that. Is it ever possible for a heredoc to not end in a newline in bash? Maybe we should comment that on the Heredoc
constructor instead. What do you think?
I'm not yet sure about that. I stumbled upon that issue while writing a package for shell script generation in the spirit of shell-monad. I do think it would be nice to force the EOF marker on a separate line because otherwise bash will extend the end of file which could lead to some really unintended results. Indeed it is IMHO not possible in bash to produce a heredoc without trailing newline. I'm not sure why a newline list terminator would break the assertion you mentioned above; can you elaborate a bit more on that?
You're right, it won't break that assertion. The solution looks good to me, feel free to turn it into a pull request.
Ok, I'll do that. I'll wait until #24 gets merged.
Consider the following here document:
If pretty printed it looks like that:
This is clearly not the intended result. Maybe we should add a trailing newline if it is not present in the Word being rendered.