-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
syntax: line continuation characters inside a string #873
Comments
mvdan
changed the title
Line continuation characters inside a string
syntax: line continuation characters inside a string
Jun 14, 2022
Thanks for raising this; I'm fairly sure this is an unintended regression. |
mvdan
added a commit
that referenced
this issue
Jul 3, 2022
As part of fixing #832, to prevent breaking some programs with escaped newlines, I went slightly too far with the tightening of the rules. The input script foo <<< \ "bar baz" would now reformat as foo <<< "\ bar baz" The script is functionally the same, but it looks objectively worse. It is harmless to allow a leading escaped newline when not quoted, as it doesn't break any programs nor result in worse formatting. Note that the script foo=\ bar will still reformat as `foo=bar`, so in that case we keep the recent change in behavior. That case is different, as we can't safely indent the continuing line - thus we can't produce good formatting unless we join the lines. While here, remove incomplete code that I had left commented out in the last patch, and then forgot to remove before merging. Fixes #873.
Err, I actually wrote a complete fix for this three weeks ago, and I was sure I had already merged it to master. Somehow, I kept it in a local branch and completely forgot about it :) See #896. |
mvdan
added a commit
that referenced
this issue
Jul 4, 2022
As part of fixing #832, to prevent breaking some programs with escaped newlines, I went slightly too far with the tightening of the rules. The input script foo <<< \ "bar baz" would now reformat as foo <<< "\ bar baz" The script is functionally the same, but it looks objectively worse. It is harmless to allow a leading escaped newline when not quoted, as it doesn't break any programs nor result in worse formatting. Note that the script foo=\ bar will still reformat as `foo=bar`, so in that case we keep the recent change in behavior. That case is different, as we can't safely indent the continuing line - thus we can't produce good formatting unless we join the lines. While here, remove incomplete code that I had left commented out in the last patch, and then forgot to remove before merging. Fixes #873.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have just noticed that recently
shfmt
has changed expectations about strings. My guess is it relates to 4556b2fI was wondering if this was expected/desired behaviour?
Originally this was fine for
shfmt
(at least with v3.4.2)Now
shfmt
wants to change it toMy personal view is the original was more readable. Otherwise changing it to something like what I have below is possibly clearer still (at least for python devs).
The text was updated successfully, but these errors were encountered: