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

Re: for loop question



On 11/03/2014 01:22 AM, Mikael Magnusson wrote:
If you look up the section "Complex Commands" in the manpage, they're
all listed fairly well explained. ...

Thanks. You know, with so many documents available, it's hard to know what it worth reading. I wish there was a sort of recommended list of docs and web sites so that one wouldn't waste so much time looking for things worth reading. I have Oliver's book
here, and at least I know it's approved.
As to the for loop, it has two different forms. They're almost so
different you could say the only thing they have in common is the word
"for" :). One is
Just those three lines might save a fella hours of grief. I intuitively expect them to be related *and* to be related to the C form, which explains my head banging over:

    for ((i = 1; [ -n ${TLC[i] ]; i++))

... because in C one can always test for the return value of anything at all and it looks so
very much like C.

    for ((i=1; (z[$([ -n "$TLC[i]" ])0]),$? == 0; i++))

... is sick and twisted, but:

    for ((i = 1; $#TLC[i]; i++))

... is sweetly, intuitively best anyway.
As a side note, if you ever want a do-while loop instead of a regular
while loop, the trick is
while just put the whole body;
       of the loop here instead;
       and the last command is;
       the terminating condition; do done
Marvelous, I was wondering about that.

If I ever master zsh I'd like to write an essay: "Zsh culture for the sweet and innocent: Truths you hold to be self-evident that aren't true any more, or the weltanschauung of weltschmertz"



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