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
- X-seq: zsh-users 29096
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Eric Cook <llua@xxxxxxx>, zsh-users@xxxxxxx
- Subject: Re: Bug/regression: tt(RANDOM) seed not updating when $RANDOM is used in a pipe
- Date: Thu, 29 Jun 2023 19:53:26 +0200
- Archived-at: <https://zsh.org/users/29096>
- In-reply-to: <CAN=4vMqjv_Y+Sg9hg_i3tC1XMp0ZLxLM8C=iYLkTsKriMEpuHg@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <25FF68CF-F93D-4745-84D1-A97A5ECCA348@gmail.com> <36f09056-0f1a-1b8a-dcf8-0ab222857ea2@gmx.com> <CAH+w=7YEgHWBroyBYOg5t7QcLpxsCmUU2f_04XPt2+sy+ayj2g@mail.gmail.com> <CAN=4vMqjv_Y+Sg9hg_i3tC1XMp0ZLxLM8C=iYLkTsKriMEpuHg@mail.gmail.com>
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? The above command will output the same two numbers on
newer versions:
% zsh -c 'repeat 2; do echo $RANDOM | cat; done'
13741
13741
% zsh-5.4.2-dev-0-mika -c 'repeat 2; do echo $RANDOM | cat; done'
4521
27867
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author