bashlex
bashlex copied to clipboard
heredoc parsing broken, if line starts with '<'
While parsing this part of a huge script (winetricks), I encountered an issue.
https://github.com/Winetricks/winetricks/blob/72b934e1e10c041ec6986f5f2fb4f143d8f6b941/src/winetricks#L16847-L16852
cat > "${W_TMP}"/config.xml <<__EOF__
<Configuration Product="ProPlus">
<Display Level="none" CompletionNotice="no" SuppressModal="yes" AcceptEula="yes" />
<PIDKEY Value="${W_KEY}" />
</Configuration>
__EOF__
Results in
bashlex.errors.ParsingError: unexpected token '\n' (position 872)
I worked around it by just replacing the <
char for the moment.
text = text.replace('\n<', '\n#<')
This issue seems to be related to #36 - my first guess is that the parser is not interpreting the string as text, but is trying to parse it as bash or something like that.