Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heredoc formatting in the bash lexer is not correct #27

Closed
moesasji opened this issue Dec 25, 2020 · 6 comments
Closed

Heredoc formatting in the bash lexer is not correct #27

moesasji opened this issue Dec 25, 2020 · 6 comments

Comments

@moesasji
Copy link

Currently vis has a set of patches contributed by @silasdb aiming to improve the formatting of heredocs: fix ending delimiter and a set to recognize <<- here and here.

However even with these patches the formatting is not yet correct for all correct usages of heredoc as it doesn't deal correctly with spaces between << and the delimiter. Moreover the formatting fails when the first delimiter is being quoted to prevent variable expansion. As a result fixing this appears not that trivial.

I've attached a test-file that highlights the above problems as this is easier to show than explain in part based on this tutorial that are worth fixing and probably a useful step to get this working correctly.

File including valid usage of heredoc: test-bash.zip

@silasdb
Copy link

silasdb commented Dec 28, 2020 via email

@moesasji
Copy link
Author

I get the same error message on Slackware Current if I use lua 5.3.
The tests complete without error if I use lua 5.1 (still the default one)

@orbitalquark
Copy link
Owner

orbitalquark commented Dec 28, 2020 via email

silasdb added a commit to silasdb/scintillua that referenced this issue Jan 22, 2021
It works with ordinary heredocs as well as those preceded by "-"
(hifen) and surrounded by quotes, but it still doesn't recognize them
if there are spaces between <<- and the delimiter name (see issue orbitalquark#27).
silasdb added a commit to silasdb/scintillua that referenced this issue Jan 22, 2021
@silasdb
Copy link

silasdb commented Jan 22, 2021 via email

@moesasji
Copy link
Author

moesasji commented Jan 22, 2021

@moesasji, another issue: the example you attached has ending delimiters with trailing spaces. The ending delimiter is handled by bash (and the classic Bourne shell) literally, which means that, in this context, a literal space is necessary for the starting delimiter.

Many thanks for working on this @silasdb; the trailing space example is probably just a left-over from copy/pasting the examples from random websites as I couldn't find clean info on what exactly the grammar for HEREDOC is. It is not something I spotted as Vim mostly handled the cases correctly.

As having such trailing whitespaces be relevant for the delimiters is generally a very bad idea it is probably indeed best to just remove that trailing whitespace from my test-example as you did.

@orbitalquark
Copy link
Owner

I'm going to close this, as the changes in 956e4ce pass all but the "\EOF" test in the test zip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants