zsh-workers
 help / color / mirror / code / Atom feed
* Bug: redirecting to /dev/stdout 3x in a row
@ 2022-07-13 17:12 Paul
  2022-07-13 17:28 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Paul @ 2022-07-13 17:12 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

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.

Have a good day.

[-- Attachment #2: Type: text/html, Size: 377 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug: redirecting to /dev/stdout 3x in a row
  2022-07-13 17:12 Bug: redirecting to /dev/stdout 3x in a row Paul
@ 2022-07-13 17:28 ` Bart Schaefer
  2022-07-13 17:36   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2022-07-13 17:28 UTC (permalink / raw)
  To: Paul; +Cc: Zsh hackers list

On Wed, Jul 13, 2022 at 10:13 AM Paul <paulsaksela@gmail.com> 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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug: redirecting to /dev/stdout 3x in a row
  2022-07-13 17:28 ` Bart Schaefer
@ 2022-07-13 17:36   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2022-07-13 17:36 UTC (permalink / raw)
  To: Paul; +Cc: Zsh hackers list

On Wed, Jul 13, 2022 at 10:28 AM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> Hmm.  It's unclear that this is a bug (as opposed to user error).
>
> There's nothing the shell can do about this, you've effectively
> instructed it to go into an infinite loop.

There may be a knock-on bug here that this can't be interrupted from
the keyboard (probably because the "echo" command itself has already
finished and now it's just the redirected output going round in
circles on its own).


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-13 17:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 17:12 Bug: redirecting to /dev/stdout 3x in a row Paul
2022-07-13 17:28 ` Bart Schaefer
2022-07-13 17:36   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).