-
Notifications
You must be signed in to change notification settings - Fork 1.2k
allow space before heredoc name #5778
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
Comments
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). |
yes if the error is improved to say "did you mean |
That section of the spec doesn't spell out the expected whitespace behavior, but all the examples there are tight. FWIW, BusyBox allows whitespace there too, so I'm sure there's another part of the spec (probably somewhere in some of the token parsing language) that talks about it more generally, and all the other redirection operators are well-known to allow whitespace around them, so it's reasonable to expect the heredoc would too (given it's also a redirection operator). Another place that allows spaces, and where I know the author has very meticulously read the relevant specs is (So TLDR, I think allowing spaces here is reasonable and consistent with the relevant standards we're emulating, if the parser doesn't get too complex in doing so.) |
Yup, looking through how |
in bash, this is allowed:
Dockerfile are quite pedantic about no space between
<<
and nameEOF
, 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.The text was updated successfully, but these errors were encountered: