Stub Generator Issue

Hi CG Staff.

Just wanted to point out an issue with the stub generator. If the generator code is:

read n:int
loopline n number:int

in Bash this is produced:

read n
for (( i=0; i<n; i++ )); do
    read number
done

when it should be something like this:

read n
read -a inputs
for (( i=0; i<n; i++ )); do
    number=${inputs[i]}
done

The first code snippit reads n entire lines, where the second reads a single line of n space separated integers (as intended).

I think that this should be fixed, since it works properly for every other language as far as I can tell.

The only “problem” I could see is that it does more than the stub for other languages, by putting the data in an array. But the python and python3 templates also do a lot in that direction, so I guess it’s not that big a deal.

On the other hand, we can also do it this way:

read n
for (( i=0; i<n; i++ )); do
    read -d' ' number
done

Yeah, this difference already exists. Ruby creates an array, Java doesn’t. Doesn’t matter too much I think.