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

syntax: allow escaped newlines to precede unquoted words again #896

Merged
merged 1 commit into from
Jul 4, 2022

Conversation

mvdan
Copy link
Owner

@mvdan mvdan commented Jul 3, 2022

(see commit message)

Fixes #873.

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.
@mvdan mvdan merged commit 4723414 into master Jul 4, 2022
@mvdan mvdan deleted the word-leading-escaped-newline branch July 13, 2022 12:11
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

Successfully merging this pull request may close these issues.

syntax: line continuation characters inside a string
2 participants