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

for loop question



test()
{

    # THIS WORKS  FINE:

    i=1
    while [ -n "$TLC[i]" ]; do
      let i=i+1
      print -ru2 $TLC[i]
    done

    # THIS WORKS FINE:

    for ((i=1; i<6; i++))
    do
      print -ru2 $TLC[i]
    done

    # ... BUT THIS FAILS WITH "BAD OUTPUT FORMAT SPECIFICATION":

    for ((i=1; [ -n "$TLC[i]" ]; i++))
    do
      print -ru2 $TLC[i]
    done
}

I've fiddled around with various modifications but it seems to dislike " [ -n "$TLC[i]" ] " even though the 'while' loop is happy with it. That expression evaluates to true or
false, does it not? So why won't 'for' swallow it?



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