From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 988 invoked by alias); 2 Nov 2014 23:31:42 -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: 19315 Received: (qmail 3108 invoked from network); 2 Nov 2014 23:31:40 -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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1414970652; bh=hILA3hD0RxMmIJu1Ph6BbG/bUwxYaSb5rMKSPHn94TI=; h=cc:In-reply-to:From:References:To:Subject:Date:From:Subject; b=Yzo0ORq7DK5CyMmCy4A3LHeybVZao8pFV7PWSUEYx7I5LYa4Wp0JYMPJRQNLtsUfM+T9xIIjBYt9wfudwOdmiRU2nA16V7RijuKYdf2vka4LXn+uY8ajwwnc7hRT4jnTxAvGJRMDr8Bf08MH0qyzdM3Tc7kq9oA2KWCk+rYuqEJN606ZgZRYYtkUiSlxsDAF0D0+s1PX1H20L1DBrm4wKXtoxgTf1w3VuqNLQ6Za9VLP3Nhw/9jAWVJGuMGz0mxcYO9PQDvJ0tx8bPMVOX7/COzI+1SHsmn4AQe8mHwgWqugsd3SoTdRVk1yPvQjR3a9AkfNCASJslB2Vp+t1nuohQ== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.co.uk; b=G2arrpqWlfGqWTVl16DU1s3D4sDKrN/hFXwXnWmxETuUjAWd6lrxymVXtvGkMPxxZ0MKUmtJWB8IgSIp/OX1wRQU64VVqKkZj6H2idXAh2GluVpQO+qvYnrfSfFt7lLMnWSZZ1taMSyJBNAGDGZWg0TBLaTWcZd7AyCiY+Auh6iOIUbATewMvUO3XxtttFSN6mHuSjQLgUOs4p0f3tB/p/2CsZ/TebtQurthIxbh0Ps4Zp2I9VEE9tRW1694ltR9GwPWc/SDR6XQgnr0C3kZ+5YrDWv1UpNjhAYQIjT+o0b1KSVyKh21heBzNOXAIcDot7c278bow2CYLfmQ4MBxBA==; X-Yahoo-Newman-Id: 501561.60862.bm@smtp135.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 9wi2vNQVM1mLdjTZIyyNTRPZ4R18BvWi1hzkLvJIa6ZgGRs ApcV427q69Q4yNrzj_NBkX7nkYX2tob0PyqHmImn71fYgzq.yxyiMyZsOS09 bUkcqqmuoUfJ7FUeN.bF4menJcLWsONQEK.Rh11vRL0UKhTZPtTgW2yAPMUI Gzoh.sx3nFzZTrnhq7l0AdyPl6HoGgK3.f7cFnD_uJpaHz_Js7R1JoxJno.L 8tLcqPZVCUPJRNYorw7CqTl25kl54TAEBFJ9k7XUri.tCSkuA6I4aBrASHyD CLuynu0i8DlSFpZTCDYm7u86biXuy2HHp35xrpq_QaCzsMdVeXLllJHF4BtF sXk1_QYt1kdFXcJSnILIXE39n1VkvTYzytUdQaIW8yv7HSLLxfUDo1xbYrTE Oe2vlWRMOIshl5uiJFNCZWC2wRm_FZSwVGFoY4yjo9ifrFGEIXu58HDs4APf 5p_DHBrDnDqFq_7FFUmFr.Rgff5EXBGJVHt.KeRWFz8x0cMlDyFish9e72Ni rO0KLW58tKADOjM_pTgcymkL_m0Q- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- cc: zsh-users@zsh.org In-reply-to: <5456B3E6.4040907@eastlink.ca> From: Oliver Kiddle References: <5456984A.3020001@eastlink.ca> <20141102213713.GA4412@chaz.gmail.com> <5456B3E6.4040907@eastlink.ca> To: Ray Andrews Subject: Re: for loop question MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16779.1414970593.1@thecus.kiddle.eu> Date: Mon, 03 Nov 2014 00:24:11 +0100 Message-ID: <16789.1414970651@thecus.kiddle.eu> Ray Andrews wrote: > > You could with: > > > > for ((i=1; (z[$([ -n "$TLC[i]" ])0]),$? == 0; i++)) > > print -ru2 -- $TLC[i] > > > > (not that you would want to). > No. That is pure sadism ;-) ;-) > > But it does show that 'for ((' CAN stop and digest ' [ -n "$TLC[i]" ] > ' if it wants too, > it just has to make it obscenely difficult. Why can't the truth test of > a command just be taken > as 'arithmetic' plain and simple? Inside of (( ... )) is arithmetic context. So different syntax is valid there. [ is just a command. Look at the error message you get if you put it there: % for ((; [ -f foo ] ; )) echo true zsh: bad output format specification Zsh sees the square brackets and in arithmetic context, square brackets are used for selecting an output format, specifically a number base. For example: % echo $(( [#2] 37 )) 2#100101 There's also a command named true which just returns true. So what do you think the following might do: % for ((; true ;)) echo true! This actually looks for the variable $true and interprets it as a number. As you can see, the syntaxes conflict. While we could add a simple way to escape back into normal syntax from arithmetic syntax, it'd be no nicer than the existing alternatives. Oliver