Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

while loop grammar question




I probably know the answer to this somewhere in the back of my head but right now it eludes me:

#!/usr/bin/zsh

for ((aa=1; aa < 10; aa++))
{
    echo $aa
}

for ((aa=1; aa < 10; aa++)); do
{
    echo $aa
}
done

aa=1
while (( aa < 10 )); do
{
    echo $aa
    let aa++
}
done

# return

aa=1
# This escape test isn't captured:
while (( aa < 10 ))
{
    echo $aa
    let aa++
}    

 
... the for loop is fine with or without the 'do/done' construction but the while loop requires it -- it runs on forever otherwise.  The echo and the increment are looped over but it won't break.  I must know this, but right now it has me scratching my head.




Messages sorted by: Reverse Date, Date, Thread, Author