focusaurus / atom-format-shell

Format shell script from within atom text editor
MIT License
6 stars 1 forks source link

Incorrect formatting of IFS joined arrays in arithmetic expressions #13

Closed leagris closed 3 years ago

leagris commented 3 years ago

Arrays joined using the $IFS environment variable (${array[*]}) within an arithmetic expression are, wrongly reformatted as array[*].

#!/usr/bin/env sh
values=(10 3 7 5 2 4 8 3)
_OIFS=$IFS
IFS=\+
sum=$((${values[*]})) #42
IFS=$_OIFS
printf %d\\n $sum

sum=$((${values[*]})) is erroneously reformatted as sum=$((values[*]))

focusaurus commented 3 years ago

@leagris thanks for the report. Could you file that upstream in https://github.com/mvdan/sh please since that's the utility that actually does the formatting. This atom plugin just calls mvdan/sh to do the formatting.

leagris commented 3 years ago

Thank-you for the reminder!

My apologies, now reported as https://github.com/mvdan/sh/issues/616