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

Formatting suggestion: if-blocks with multiple conditions #1068

Open
mikez opened this issue Mar 31, 2024 · 0 comments
Open

Formatting suggestion: if-blocks with multiple conditions #1068

mikez opened this issue Mar 31, 2024 · 0 comments

Comments

@mikez
Copy link

mikez commented Mar 31, 2024

Hi @mvdan, I have a formatting suggestion involving if-blocks.

Instead of doing this:

a='aaa'
b='bbb'
c='ccc'
if [[ 
    $a == 'aaa' &&
    $b == 'bbb' &&
    $c == 'ccc' ]] \
    ; then
    echo yes
    # ...
fi

reformat like this:

a='aaa'
b='bbb'
c='ccc'
if [[
    $a == 'aaa'
    && $b == 'bbb'
    && $c == 'ccc'
]]; then
    echo yes
    # ...
fi

The formatting is inspired by what Python does with the black formatter. I think it makes the code more readable. (For operator placement, see also here.)

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

No branches or pull requests

1 participant