sh
sh copied to clipboard
syntax: multiline arrays are not intended correctly with "$()" in array member
Given the following code:
RUN_CMD=("$(foo)" \
"bar")
When I format it with shfmt I get:
RUN_CMD=("$(foo)"
"bar")
The backslash is removed at the end (which is OK), but the second line is not intended. This only occurs when there is the $( as the first value in the array, with ( the issue does not occur.
Minimal repro:
$ cat f.sh
arr1=($(foo)
bar)
arr2=(foo
bar)
$ shfmt f.sh
arr1=($(foo)
bar)
arr2=(foo
bar)