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: trailing white space added after opening parenthesis '(' #814

Closed
ContinuousCaffeniation opened this issue Feb 17, 2022 · 1 comment · Fixed by #869 or #874
Closed

syntax: trailing white space added after opening parenthesis '(' #814

ContinuousCaffeniation opened this issue Feb 17, 2022 · 1 comment · Fixed by #869 or #874

Comments

@ContinuousCaffeniation
Copy link

In the second example below, a trailing blank/ white space is inserted after first opening '(' symbol, this is indicated through '^'. The expectation is like in first example above. This seems to happen when opening a subshell first after opening brackets of another subshell.
shfmt is called without any parameters in this case.

#!/bin/bash

# OK - no blank
(
    cd .
    (echo "Hello world!")
)

# nok - blank ^ after first (
(^ 
    (echo "Hello world!")
)
@mvdan
Copy link
Owner

mvdan commented Feb 19, 2022

Thanks, this definitely sounds like a bug. We have logic to print two nested subshells in a single line as ( ( rather than ((, because the latter is ambiguous syntax. The logic is likely kicking in with multiple lines when it shouldn't be. Should be a relatively easy fix if anyone wants to take a look :)

@mvdan mvdan changed the title shfmt: trailing white space added after opening parenthesis '(' syntax: trailing white space added after opening parenthesis '(' Mar 21, 2022
@riacataquian riacataquian self-assigned this May 27, 2022
riacataquian added a commit to riacataquian/sh that referenced this issue May 31, 2022
we want white space on nested subshells if its in a single line since
its ambiguous, eg we want `( (` over `((`

this shouldn't be the case for multiple lines- fix the logic that adds
white space to only do so if the two subshells are in the same line

fixes mvdan#814
riacataquian added a commit to riacataquian/sh that referenced this issue May 31, 2022
we want white space on nested subshells if its in a single line since
its ambiguous, eg we want `( (` over `((`

this shouldn't be the case for multiple lines- fix the logic that adds
white space to only do so if the two subshells are in the same line

fixes mvdan#814
riacataquian added a commit that referenced this issue Jun 6, 2022
we want white space on nested subshells if its in a single line since
its ambiguous, eg we want `( (` over `((`

this shouldn't be the case for multiple lines- fix the logic that adds
white space to only do so if the two subshells are in the same line

fixes #814
riacataquian added a commit to riacataquian/sh that referenced this issue Jun 6, 2022
we want white space on nested subshells if its in a single line since
its ambiguous, eg we want `( (` over `((`

this shouldn't be the case for multiple lines- fix the logic that adds
white space to only do so if the two subshells are in the same line

fixes mvdan#814
riacataquian added a commit that referenced this issue Jun 6, 2022
we want white space on nested subshells if its in a single line since
its ambiguous, eg we want `( (` over `((`

this shouldn't be the case for multiple lines- fix the logic that adds
white space to only do so if the two subshells are in the same line

fixes #814
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants