From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8440 invoked by alias); 2 Nov 2014 21:44:46 -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: 19312 Received: (qmail 14020 invoked from network); 2 Nov 2014 21:44:36 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=wBumEXxbAb7PAgIryycQR0cRj7as2V9JW8yJ+rP72N4=; b=nIpk6guTBIq3QLfltGJ6M53ucGkVSHhGTJXdQSH8EwR/Bj5OQKtVKlJgXjH0EgO3+X ZKg94BaKcNEBcQOLiNR8n+OEpj506qzEz7QbOb4ElDak4U8aQ8V9/bEyEBjOmNcQngzB PiUkYCo55lHCaguYXJN1ZJUt0KypLqJ2Ih2faXK6nw3e9Lg/vbZZ13ra+EHeePjn4PfW Im8jPwQ7hTSVoxTLfbnu7ctwkjQPWrstG8zpCCBhaa6Qtas+hBI8BHWXHuwfyeEoITmW c9NoCCAfMnzX6rq7C6Z8uh11nxZyVZCbMv0uQhV1QE37hyUMk1v+DsknMmpoHeSmonK9 8qiQ== X-Received: by 10.180.102.135 with SMTP id fo7mr12124622wib.79.1414964234980; Sun, 02 Nov 2014 13:37:14 -0800 (PST) Date: Sun, 2 Nov 2014 21:37:13 +0000 From: Stephane Chazelas To: Bart Schaefer Cc: Ray Andrews , Zsh Users Subject: Re: for loop question Message-ID: <20141102213713.GA4412@chaz.gmail.com> Mail-Followup-To: Bart Schaefer , Ray Andrews , Zsh Users References: <5456984A.3020001@eastlink.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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] (not that you would want to). Here, you more likely want: for i ("$TLC[@]") print -ru2 -- $i or print -rlu2 -- "$TLC[@]" or: for ((i = 1; i <= $#TLC; i++)) print -ru2 -- $TLC[i] Or (to print only till the first empty element): for ((i = 1; $#TLC[i]; i++)) print -ru2 -- "$TLC[i]" Or: print -rlu2 -- "${(@)TLC[1,TLC[(i)]-1]}" -- Stephane