mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.2k stars 340 forks source link

shfmt throws errors on variable declaration with brace expansion #986

Closed Popkornium18 closed 1 year ago

Popkornium18 commented 1 year ago

A convenient way to set a lot of variables to the same value is this:

declare -i VAR_{1..4}=0
echo ${VAR_1@A} ${VAR_2@A}
"declare -i VAR_1='0' declare -i VAR_2='0'"

However, when shfmt encounters such a statement it prints: "invalid var name".

mvdan commented 1 year ago

Duplicate of https://github.com/mvdan/sh/issues/858.