Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: for loop question
- X-seq: zsh-users 19320
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Subject: Re: for loop question
- Date: Mon, 03 Nov 2014 09:26:47 -0800
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <CAHYJk3T4=8fxBKFKJ_7ppLWrNPd4sV9kd9Jss3=f8WihwwgXXQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <5456984A.3020001@eastlink.ca> <CAH+w=7aWS0xyS4CXRJBphDjesfUFQOsyJRMaG3RZRxmuj7xkOg__20885.3257158355$1414962125$gmane$org@mail.gmail.com> <20141102213713.GA4412@chaz.gmail.com> <CAHYJk3ThuftERfPB0k=MG2UV1+f4CgQ-7_x4d=8bKHUhUmU58A@mail.gmail.com> <5456E6EA.2050806@eastlink.ca> <CAHYJk3T4=8fxBKFKJ_7ppLWrNPd4sV9kd9Jss3=f8WihwwgXXQ@mail.gmail.com>
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