bashlex icon indicating copy to clipboard operation
bashlex copied to clipboard

heredoc parsing broken, if line starts with '<'

Open Root-Core opened this issue 5 months ago • 0 comments

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.

Root-Core avatar Sep 13 '24 22:09 Root-Core