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: comments aren't spaced when following parentheses #839

Closed
mvdan opened this issue Apr 3, 2022 Discussed in #838 · 0 comments · Fixed by #842
Closed

syntax: comments aren't spaced when following parentheses #839

mvdan opened this issue Apr 3, 2022 Discussed in #838 · 0 comments · Fixed by #842

Comments

@mvdan
Copy link
Owner

mvdan commented Apr 3, 2022

Discussed in #838

Originally posted by antichris April 3, 2022
Is there a specific design reason why the space preceding a comment is removed when it follows an open parenthesis, or is it by accident?

Given the input

#!/bin/sh

foo() { ## (bar, [baz])
	:
} ## qux

corge() ( ## (grault, [garply])
	:
) ## waldo

_=$( ## lorem ipsum
	:
) ## dolor sit amet

shfmt yields

#!/bin/sh

foo() { ## (bar, [baz])
        :
} ## qux

corge() (## (grault, [garply])
        :
) ## waldo

_=$(## lorem ipsum
        :
) ## dolor sit amet
antichris added a commit to antichris/go-sh that referenced this issue Apr 5, 2022
Also applies to sub-shell functions and command substitutions (including
the deprecated legacy back-tick syntax).

Fixes mvdan#839.
@mvdan mvdan closed this as completed in #842 Apr 7, 2022
mvdan pushed a commit that referenced this issue Apr 7, 2022
If a comment isn't at the start of a line, it must follow a space at all times.
We enforced this in general, but not in some edge cases, such as when
an inline comment followed the start of a subshell or command substitution.

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

Successfully merging a pull request may close this issue.

1 participant