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 29091
- From: Eric Cook <llua@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Bug/regression: tt(RANDOM) seed not updating when $RANDOM is used in a pipe
- Date: Wed, 28 Jun 2023 22:46:35 -0400
- Archived-at: <https://zsh.org/users/29091>
- In-reply-to: <25FF68CF-F93D-4745-84D1-A97A5ECCA348@gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <25FF68CF-F93D-4745-84D1-A97A5ECCA348@gmail.com>
- Ui-outboundreport: notjunk:1;M01:P0:jCVspOlTSO4=;yLIEp2TKGVtjk/8coDNQ9mNui3G /gUI50hZIJEgjx8+Z6ez2kimPSfXqdSfWPn1FgPOis8hVu0a/ak07DwG9izRP+NemXxebkmQP 1/mt5CLyMtr2TZkXqwALTm3jfg+irpKYB7WA9JnOzVmu3F6I7w7csMSs34R36EsJstMATPmO3 raqRhkp2fmisGME4L1U9lfUU1qI8R2YBg59xSWvQXFTDgeOx6Cq6ZkfHkH6vQk14cFmBXpQJ0 JTW0B7hgUo7rpSfA05Tik3jG9HXJQYdz0vlDURa+JqGDoWXhgcAoQSRke/qHPtVx2CsElPUxl ByoTG/StN4Ar0C5xQDOy+LakG+MkpFa5XJj1KuYeOCBRznEXzasximv3vFaUMZLpWi53Q8iZ7 DZsaKXp5CT0Ca0Xy+jcQ2LhsuQSAPFngrgAYOJtrM2xj/dn8LyTnuXo9I6Tg1athVJLd1SaYQ 06suc1XPo2ny70hIxNM3NDQTJ9u45qQ9DuuSGDfBp7oFBrG+5s051upI9z8QQSuPAndFZxUDK IFi6+anD9yNDtcf1syR7/eNENwrXUEKn8rQHWESgkYwl+v0EtY1qXq4YGnq6T++BcRCzenNlz 6+iv4sElkaKj7vyoJH9dmbvjaCKPcuwcpZQXW8FRQLUj40nhxldrWyuaUTAstHt3wu5CU/UNp w2Rr3IG3DDTMcfo5hFdvp1YC/91Vpr0hrpeo39AqB2cqe+T5LqkOfg0azNwKcZrTKWt5CkESp xT4hfiW+QCkSSYaoCJCP1vU6FZ5igj2lwmDRLXAX1kJXoL9e25cGRZjrCMiJFHQxk0wzkKGRf 3Llelqu9lJ4lPFlwHu1hYa3pwy7r/TH78aQ1sspDqDl55lt3n5J6i3gYvzaWZAIkB5OqzW1/j NaFtsD6Bx+bOULtfCYz2odoQsC190Y7aX86ptLtAqSBY7AvNl8Qes9KhJBffGimHLZ60gEQji KLICYYjUh80kF6ek0wvhkZEpZAA=
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? Personally, I'd
argue it's a bug. Unfortunately, my C isn't good enough to try to fix and
submit a patch myself, but I tried to make this bug report as helpful as
possible.
[1] https://sourceforge.net/p/zsh/code/ci/faf0035e532cde45528806e7a05ad28a0ab7c0fb/
RANDOM <S>
A pseudo-random integer from 0 to 32767, newly generated each time this parame‐
ter is referenced. The random number generator can be seeded by assigning a nu‐
meric value to RANDOM.
The values of RANDOM form an intentionally-repeatable pseudo-random sequence;
subshells that reference RANDOM will result in identical pseudo-random values
unless the value of RANDOM is referenced or seeded in the parent shell in be‐
tween subshell invocations.
The LHS of the pipe should be a subshell, so the behavior is intentional.
RANDOM has be documented to work that way since it's introduction and this is commonly
misreported as a bug.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author