nco / swamp

Automatically exported from code.google.com/p/swamp
0 stars 1 forks source link

Fix shell parser to handle arrays and looping more like bash #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
To do for-loops, SWAMP currently adheres to a misinterpretation of shell
specifications. 

Therefore, in the following loops,
a=(1 2 3)
for i in $a; do
echo $i
done

b=`seq 3`
for i in $b; do
echo $i
done

... both produce the same output.  In bash/sh, the range is supposed to be
a whitespace-delimited set, instead of an array.  In bash, if you provide
an array to the for-loop, it will treat the first element as the entire
range, meaning that the loop will only iterate multiple times if the first
element is itself a whitespace-delimited range.

SWAMP works this way because of the specification was initially
misinterpreted.  It needs to be fixed.

Original issue reported on code.google.com by daniel2...@gmail.com on 3 May 2008 at 12:33