From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18409 invoked by alias); 4 Nov 2014 02:39:59 -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: 19322 Received: (qmail 26568 invoked from network); 4 Nov 2014 02:39:57 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.2 Date: Tue, 4 Nov 2014 10:29:42 +0800 From: Han Pingtian To: zsh-users@zsh.org Cc: Bart Schaefer , Ray Andrews Subject: Re: for loop question Message-ID: <20141104022942.GB2871@localhost.localdomain> Mail-Followup-To: zsh-users@zsh.org, Bart Schaefer , Ray Andrews References: <5456984A.3020001@eastlink.ca> <20141102213713.GA4412@chaz.gmail.com> <20141104015639.GA2871@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141104015639.GA2871@localhost.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14110402-0021-0000-0000-000005E1D54D On Tue, Nov 04, 2014 at 09:56:39AM +0800, Han Pingtian wrote: > On Sun, Nov 02, 2014 at 09:37:13PM +0000, Stephane Chazelas wrote: > > 2014-11-02 13:00:14 -0800, Bart Schaefer: > > > > 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? > > > > > > The double parents (( )) are special arithmetic syntax. You can't use an > > > ordinary shell command like "test" ( for which "[" is an alias) inside that > > > construct. > > > > You could with: > > > > for ((i=1; (z[$([ -n "$TLC[i]" ])0]),$? == 0; i++)) > > print -ru2 -- $TLC[i] > > > What does the (z[$([ -n "$TLC[i]" ])0]) mean, please? > I think I have got the meaning of it. The goal is to run '[ -n "$TLC[i]" ]' in a math context, so embed the testing in the subscript of 'z[..]'. The 'z' will be explained as a array in this math context, the value of '$z[...]' is ignored, only the result of '[ -n "$TLC[i]" ]' is compared with 0.