mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.14k stars 338 forks source link

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

Closed mvdan closed 2 years ago

mvdan commented 2 years ago

Discussed in https://github.com/mvdan/sh/discussions/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 ```sh #!/bin/sh foo() { ## (bar, [baz]) : } ## qux corge() ( ## (grault, [garply]) : ) ## waldo _=$( ## lorem ipsum : ) ## dolor sit amet ``` `shfmt` yields ```sh #!/bin/sh foo() { ## (bar, [baz]) : } ## qux corge() (## (grault, [garply]) : ) ## waldo _=$(## lorem ipsum : ) ## dolor sit amet ```