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

Re: Bug/regression: tt(RANDOM) seed not updating when $RANDOM is used in a pipe



On Thu, Jun 29, 2023 at 7:53 PM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> On 6/29/23, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
> > On Thu, Jun 29, 2023 at 7:43 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
> > wrote:
> >>
> >> On Wed, Jun 28, 2023 at 7:46 PM Eric Cook <llua@xxxxxxx> wrote:
> >> >
> >> > On 6/28/23 16:10, Jon Oster wrote:
> >> > > In 5.8.1, $RANDOM seems not to update its state when the command
> >> > > $RANDOM
> >> > > was used in is piped somewhere. For example:
> >> > >
> >> > > Is this considered a bug? Or is it intended behaviour?
> >> > >
> >> > > [1]
> >> > > https://sourceforge.net/p/zsh/code/ci/faf0035e532cde45528806e7a05ad28a0ab7c0fb/
> >> >
> >> > The LHS of the pipe should be a subshell, so the behavior is
> >> > intentional.
> >>
> >> This was, however, an unanticipated side-effect of the referenced
> >> commit.  It changed behavior (that, before, did not conform to the
> >> documentation) without that fact being called out in any of our files
> >> that serve as release notes.
> >>
> >> It opens the question of whether anything else that previously was
> >> "pre-fork" might have changed behavior at that point.
> >
> > Perhaps things of this sort?
> >
> >     % echo ${foo::=bar} | cat
> >     % zmodload zsh/system; echo $sysparams[pid] | cat
> >
> > I cannot reproduce the 5.4.2 behavior reported by Jon, so I cannot
> > verify whether the identified commit affects these test cases.
> >
> >     % docker run --rm zshusers/zsh:5.4.2 zsh -c 'repeat 2 echo $RANDOM |
> > cat'
> >     15988
> >     9706
>
> Yes, you can?

Of course!

I can also confirm that the two test cases I posted above behave
differently in zsh 5.4.2 and 5.9. In all these cases 5.9 behaves as I
would expect, and the behavior of 5.4.2 is surprising to me.

Roman.




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