Open Kreyren opened 1 year ago
Imagine:
a=idc
b=${a}else
You have to use curly braces in such a statement... Otherwise shell would try to find variable by name 'aelse'
I prefer not to use them for simple variable expansion because it's 2 additional characters
Imagine:
a=idc b=${a}else
You have to use curly braces in such a statement... Otherwise shell would try to find variable by name 'aelse'
I prefer not to use them for simple variable expansion because it's 2 additional characters -- @aeiplatform (https://github.com/koalaman/shellcheck/issues/2836#issuecomment-1748231679)
Agree that the b=${a}else
and parameter expansion are a valid usage that should be excluded from the check.
This is mainly for the source code alike https://github.com/armbian/build/blob/b6fea441d1850ffd512bcd1d5f65091fdf6e5157/lib/single.sh where people put the braces on every single variable that looks ugly and bloated to me as it's adding useless characters.
Lot of people seems to write the code with
${var}
where the common justification seems to be that adding the braces is a replacement for double-quoting to prevent globbing and word splitting (SC2086).Additionally it seems to make the code harder to read and is messy as the alternative
$var
does the same thing -> Proposing to add check that will discourage the use of braces unless they are used in a variable expansion.