Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: shortloops for while?
- X-seq: zsh-users 12972
- From: Peter Stephenson <pws@xxxxxxx>
- To: "Zsh Users" <zsh-users@xxxxxxxxxx>
- Subject: Re: shortloops for while?
- Date: Tue, 17 Jun 2008 14:52:19 +0100
- In-reply-to: <2d460de70806170642v5340abf9o79af3460c4e1008d@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <2d460de70806170642v5340abf9o79af3460c4e1008d@xxxxxxxxxxxxxx>
"Richard Hartmann" wrote:
> Hi all,
>
> I am using setopt shortloops, which allows me to do
>
> for i in *; echo $i
>
> Along the same lines, I would want to be able to do
>
> while true; echo this is neat
>
>
> Is there any reason this is not possible? Is it an oversight? Could
> something like this be added at some point in the future?
It does appear the parser doesn't support any short looping syntax for
while. It may be to do with the fact that in regular shell parsing any
set of statements can come between the "while" and the "do":
while true; false; do echo never got here; done
This is the reason why "if" requires you to use trickery for short
"loops".
You can do
for ((;;)); echo this is not quite so neat
and if you were really desperate you could use a global alias for
the ((;;)).
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author