From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25944 invoked by alias); 3 Nov 2014 16:23:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19320 Received: (qmail 23526 invoked from network); 3 Nov 2014 16:23:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Authority-Analysis: v=2.1 cv=AduIQRnG c=1 sm=1 tr=0 a=WX1zAfUMD62odRRZjfQOeg==:117 a=WX1zAfUMD62odRRZjfQOeg==:17 a=gmhVCtT3eHoA:10 a=IkcTkHD0fZMA:10 a=yE7LGZtCLh6QbERO6zYA:9 a=QEXdDO2ut3YA:10 Message-id: <5457BAD7.8040004@eastlink.ca> Date: Mon, 03 Nov 2014 09:26:47 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.1.2 MIME-version: 1.0 To: Mikael Magnusson Cc: Zsh Users Subject: Re: for loop question References: <5456984A.3020001@eastlink.ca> <20141102213713.GA4412@chaz.gmail.com> <5456E6EA.2050806@eastlink.ca> In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit 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"