sh icon indicating copy to clipboard operation
sh copied to clipboard

syntax: inconsistent formatting for subshell's closing parentheses

Open riacataquian opened this issue 3 years ago • 1 comments

The syntax $(( and (( are ambiguous and when printing, we space the opening parentheses as in: ( (, as documented on the Caveats which is OK but we don't space for its closing parentheses. The output then looks inconsistent:

$ cat in.sh
( (foo) )
$ shfmt in.sh
( (foo))

It's not actually wrong but we can improve the output by making the space consistent:

( (foo) )

riacataquian avatar Jun 10 '22 10:06 riacataquian

I think this suggestion makes sense - we don't strictly need the space between the closing parentheses for the sake of avoiding ambiguity, but adding the space makes the formatting more consistent, which is the point of the formatter.

mvdan avatar Jun 14 '22 10:06 mvdan