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

Re: Bug? Output not flushed?



On 9/15/23, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Easily reproduced:
>
> % { print XXX; return 0; } >| /tmp/newfile; print $(</tmp/newfile)
> % print $(</tmp/newfile)
> XXX
>
> That is, when a return statement appears in a current-shell complex
> list, the output is not flushed until the parser reaches the top level
> again.

I'm not sure if that diagnosis is correct, look at this:
% { print XXX; return 0; } >| /tmp/newfile; echo hello; print $(</tmp/newfile)

and if you put a sleep 10 in there, it still completes immediately,
ie, does the return just return from the whole statement? Isn't that
actually expected since it's not in a function or subshell?

>  If the return statement is removed, all is well:
>
> % { print YYY; } >| /tmp/newfile; print $(</tmp/newfile)
> YYY
> %
>
> Any idea where to start looking for this?

-- 
Mikael Magnusson




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