Skip to content

Implement Proper While Support

Michael Aaron Murphy requested to merge mmstick:while into master

With these changes, the while loops in Ion will work as while loops in other shells -- executes a supplied command and checks if the exit status was a success value, and quits when it's not.

This means that you can do this in Ion now:

let a = 1;
while test $a -lt 10
    echo $a
    let a = $(echo "$a + 1" | bc)
end

And this:

while read line
    echo $line
end

Although with the second example, you'll be stuck in an endless loop as Ctrl+C / Ctrl+D doesn't work.

Merge request reports