tdenniston / bish

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.
MIT License
1.48k stars 36 forks source link

Iteration of the array elements #59

Closed egorsmkv closed 9 years ago

egorsmkv commented 9 years ago

I wrote the following script:

a = [1, 2, 3, 4];

for (u in a) {
  println(u);
}

And got a bash script:

# ...
function main () {
    for u in $a; do
        local _0="$u";
        StdLib_println "$_0";
    done;
}

function StdLib_println () {
    local s="$1";
    echo -e "$s";
}

a=( 1 2 3 4 );
main;

But when you start getting only the first element.

tdenniston commented 9 years ago

Ah, ok. I think I know what the problem is there. Thanks for reporting. It should be simple to fix.

tdenniston commented 9 years ago

@eg0r Can you verify that it's fixed for you now?

egorsmkv commented 9 years ago

@tdenniston Checked, there is no problem now.

And now the question is: the number of semicolons are not supported yet?

a = [1.1, 1.2, 1.3];
egorsmkv commented 9 years ago

@tdenniston By the way, why not remove () next to the names of functions? Or is it important for some versions of bash?

tdenniston commented 9 years ago

@eg0r Floating point numbers (numbers with decimal points) are not supported yet. That's a limitation of bash. I have to figure out what to do about that. And, I should remove () next to functions. I thought they were necessary, but I was wrong.