Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: shortloops for while?
- X-seq: zsh-users 12973
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Richard Hartmann <richih.mailinglist@xxxxxxxxx>
- Subject: Re: shortloops for while?
- Date: Tue, 17 Jun 2008 14:56:32 +0100
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <2d460de70806170642v5340abf9o79af3460c4e1008d@xxxxxxxxxxxxxx>
- Mail-followup-to: Richard Hartmann <richih.mailinglist@xxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <2d460de70806170642v5340abf9o79af3460c4e1008d@xxxxxxxxxxxxxx>
On Tue, Jun 17, 2008 at 03:42:12PM +0200, 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?
[...]
The normal syntax for while is:
while list1-of-comands
do list1-of-commands
done
So you have to have a way to tell while where the first list of
commands end.
You can use the short version only when list1-of-commands is
((...)) or [[...]] and list2-of-commands is bound by {} or ().
while ((1)) {echo this is neat}
while true; echo this is neat
would be parsed as while and the first two commands of
list1-of-commands.
It's true that zsh could probably have been made to allow:
while { list1 } { list2 }
There might be good reasons why it's not supported though.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author