On Mon, Jan 12, 2015 at 05:26:15PM +0800, l_j_f wrote:
>         for ((idx=0; idx<3 && idx != current; idx++)); do
>                 echo $idx
>         done

> # I think it should be 
> 0
> 2

No, this is not a bug.  The second expression in "for ((expr; expr; expr))"
tells bash when to terminate the entire for loop.  So, the loop terminates
when idx == current.

If you just want to skip a single iteration when idx == current, do it
like this:

for ((idx=0; idx<3; idx++)); do
    if ((idx == current)); then continue; fi
    echo "$idx"
done

Reply via email to