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
6.98k stars 332 forks source link

different indent when pass environment variables with command substitution #1015

Open chnkd opened 1 year ago

chnkd commented 1 year ago
foo=foo \
    echo foo

foo=$() \
    echo foo

foo=foo \
    bar=bar \
    echo foobar

foo=$() \
bar=bar \
    echo foobar
mvdan commented 1 year ago

Sorry but I don't understand. Exactly what did you run and what happened?

chnkd commented 1 year ago

Assign a constant to foo, the code will be formatted as below:

foo=foo \
    bar=bar \
    echo foo bar

Replace with command substitution, and the indent style of formatted code is different from the above

foo=$(echo foo) \
bar=bar \
    echo foo bar
mvdan commented 12 months ago

Thanks, that does look like a bug.