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

Re: Unterminated for loop



On Tue, Jun 6, 2023 at 4:12 PM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> On 6/6/23, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
> > If I type `for x;` (without the quotes) and press ENTER in an interactive
> > zsh, I end up in PS2. However, the exact same sequence of characters is
> > treated as a complete command in a script or function. Why is that?
>
> It is accepted because SHORT_LOOPS is unfortunately set by default,
> which tends to hide a lot of syntax errors in various contexts. It's
> no surprise that it causes weird differences with script EOF vs
> accepting a single line interactively.

Tangentially, this points out that there is no way to send an EOF at
the PS2 prompt (or, likely, at any prompt other than PS1); typing
ctrl+d just lists file completions.  Even changing stty eof doesn't
work.  Nor does a custom widget that closes FD 0.

Someone please remind me what this sentence under IGNORE_EOF means?
     Also, if this option is set and the Zsh Line Editor is used,
     widgets implemented by shell functions can be bound to EOF
     (normally Control-D) without printing the normal warning message.

I guess "bound to EOF" means overriding the stty EOF character.
What's the significance of the part about the warning message?




Messages sorted by: Reverse Date, Date, Thread, Author