Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: while loop grammar question
- X-seq: zsh-users 30121
- From: Lawrence Velázquez <larryv@xxxxxxx>
- To: "Mark J. Reed" <markjreed@xxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: while loop grammar question
- Date: Sun, 08 Dec 2024 04:10:35 -0500
- Archived-at: <https://zsh.org/users/30121>
- Feedback-id: iaa214773:Fastmail
- In-reply-to: <CAA=-s3z=C2YLSMiz1cYyuCNo1pxuESZ6qvP4EQyQFT60n3+itA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <8e1cd80d-fcee-4227-93ae-de2339d066fa@eastlink.ca> <5b4a5f55-717e-4794-93d7-bfd03a955ba8@app.fastmail.com> <CAA=-s3z=C2YLSMiz1cYyuCNo1pxuESZ6qvP4EQyQFT60n3+itA@mail.gmail.com>
On Sun, Dec 8, 2024, at 3:33 AM, Mark J. Reed wrote:
> On Sun, Dec 8, 2024 at 1:45 AM Lawrence Velázquez <larryv@xxxxxxx> wrote:
>>
>> I don't know whether this behavior is intentional or not.
>> A comparable "if" command errors out:
>>
>> % cat /tmp/users-30115-4.zsh
>> if ((1))
>> {
>> print true
>> }
>> % zsh -f /tmp/users-30115-4.zsh
>> /tmp/users-30115-4.zsh:5: parse error near `\n'
>
> but if you run it interactively, you'll find that you're still in the
> `if>` condition after the close curly, So it's similar to the while
> loop; it's just not letting you get away without a *then*.
That's the whole point: it's not clear to me why short "if" and
short "while" behave differently when interrupted by EOF in a similar
way. Is it a bug? Or is the "while" body sneakily optional?
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author