Following solution found here I've tried to implement loop over a tuple in bash:
NUMBERS='1,2,3 4,5,6 7,8,9'
for TOUPLE in $NUMBERS;
do IFS=',';
set -- $TOUPLE
echo \($1, $2, $3\)
done
echo ''
for TRIPLE in $NUMBERS;
do IFS=',';
set -- $TRIPLE
echo \($1, $2, $3\)
done
These should basically be the same loops, and they should print the same output. However, when I execute the script I get the following output:
(1, 2, 3)
(4, 5, 6)
(7, 8, 9)
(1, , )
(2, , )
(3 4, , )
(5, , )
(6 7, , )
(8, , )
(9, , )
Why does the second loop acts differently from the first one?