zsh-workers
 help / color / mirror / code / Atom feed
* Bug(?) when using if list { list } syntax inside a for { } loop
@ 2011-09-05  8:47 Daniel Friesel
  2011-09-05  9:08 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Friesel @ 2011-09-05  8:47 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 595 bytes --]

Hi everyone,

It looks like it's not possible to use if [[ ]] { } syntax inside a for { } loop:

descent ~/bin > for i (*) { if [[ -r $i ]] { echo $i } }
for elif> 

when explicitly adding an else it works fine, though:

descent ~/bin > for i (*) { if [[ -r $i ]] { echo $i } else { } }

it also works when adding a semicolon to the end of the if { }:

descent ~/bin > for i (*) { if [[ -r $i ]] { echo $i }; }

I'm not quite sure if this is a bug, at least from the documentation it seems
like it should work.

zsh version 4.3.12-dev-1-cvs0820, patchlevel 1.5445

--Daniel

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug(?) when using if list { list } syntax inside a for { } loop
  2011-09-05  8:47 Bug(?) when using if list { list } syntax inside a for { } loop Daniel Friesel
@ 2011-09-05  9:08 ` Peter Stephenson
  2011-09-05 12:35   ` Daniel Friesel
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2011-09-05  9:08 UTC (permalink / raw)
  To: zsh-workers

On Mon, 5 Sep 2011 10:47:06 +0200
Daniel Friesel <derf@finalrewind.org> wrote:
> Hi everyone,
>
> It looks like it's not possible to use if [[ ]] { } syntax inside a
> for { } loop:
>
> descent ~/bin > for i (*) { if [[ -r $i ]] { echo $i } }
> for elif>

You need a semicolon or newline after the first "}", just as you would
if you were using the more standard "then" and "fi".

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug(?) when using if list { list } syntax inside a for { } loop
  2011-09-05  9:08 ` Peter Stephenson
@ 2011-09-05 12:35   ` Daniel Friesel
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Friesel @ 2011-09-05 12:35 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 233 bytes --]

On Mon, Sep 05, 2011 at 10:08:49AM +0100, Peter Stephenson wrote:
> You need a semicolon or newline after the first "}", just as you would
> if you were using the more standard "then" and "fi".

Ah, okay. Thanks for pointing it out.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-05 12:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-05  8:47 Bug(?) when using if list { list } syntax inside a for { } loop Daniel Friesel
2011-09-05  9:08 ` Peter Stephenson
2011-09-05 12:35   ` Daniel Friesel

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).