Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: while loop grammar question



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