sh
sh copied to clipboard
Formatting suggestion: if-blocks with multiple conditions
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.)