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

allow space before heredoc name #5778

Open
kasperk81 opened this issue Feb 25, 2025 · 2 comments
Open

allow space before heredoc name #5778

kasperk81 opened this issue Feb 25, 2025 · 2 comments

Comments

@kasperk81
Copy link

kasperk81 commented Feb 25, 2025

in bash, this is allowed:

cat <<       EOF      > /tmp/afile       
  stuff
  more stuff
EOF

Dockerfile are quite pedantic about no space between << and name EOF, otherwise it gives a very confusing syntax error on next line which leads user to think if heredocs are supported, then the follow up google search makes things more confusing... looks to be a simple case of a missing \s* in heredoc parser.

@thaJeztah
Copy link
Member

I know the original implementation (see #2132, moby/moby#34423) was based on https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04 - we should probably read up in that document to see how it defines handling of whitespace here.

If the spec doesn't define whitespace being supported, I'm somewhat leaning towards not allowing it (also in light of efforts in the Dockerfile syntax to provide linting errors for consistency), but we should definitely (where possible) improve errors to make it clear to the user what's wrong (i.e., if we decide based on the above to not allow whitespace, then at least a linter and/or error should indicate that it's because of whitespace).

cc @jedevc @tianon

@kasperk81
Copy link
Author

yes if the error is improved to say "did you mean <<EOF" that would suffice too (in case allowing space there is not feasible)

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

2 participants