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

Re: Bug: redirecting to /dev/stdout 3x in a row



On Wed, Jul 13, 2022 at 10:13 AM Paul <paulsaksela@xxxxxxxxx> wrote:
>
> Hello workers of zsh. I noticed that on the latest version, this command:
> ‘echo test > /dev/stdout > /dev/stdout > /dev/stdout’
> Results in an infinite loop of echoing ‘test’. This bug seems to happen only after redirecting output more than 2 times.

Hmm.  It's unclear that this is a bug (as opposed to user error).

Redirection to /dev/stdout means that "test" is copied to the output twice.
Redirecting it there again means that both of those outputs are
doubled and that's fed back to the first output.
A third time, all the previous outputs are doubled, again, including
the stuff fed back to the first, which is doubled by the second, etc.

At some point the this exceeds the amount of data that can be buffered
without flushing it, and then you end up never being able to empty the
buffer before more data goes in.

There's nothing the shell can do about this, you've effectively
instructed it to go into an infinite loop.




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