Skip to content

syntax: inconsistent formatting for subshell's closing parentheses #876

Closed

Description

@riacataquian

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) )

Activity

  1. changed the title [-]shfmt: inconsistent formatting for subshell's closing parentheses[/-] [+]syntax: inconsistent formatting for subshell's closing parentheses[/+] on Jun 14, 2022
  2. mvdan commented on Jun 14, 2022

    @mvdan
    Owner

    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.

  3. self-assigned this
    on Jun 20, 2022
  4. added a commit that references this issue on Jun 3, 2026
    3aa9ec1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址