Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 22
    well, I didn't expect this :D Commented May 19, 2022 at 13:22
  • 4
    @ilkkachu see also austingroupbugs.net/view.php?id=983#c3281 for an even more convoluted alternative. Commented May 19, 2022 at 13:38
  • 5
    @StéphaneChazelas On the one hand, this is certainly an... imaginative solution. But on the other hand, and I hope you don't mind my saying this, it is absolutely hideous! Me, I'd never use it; it's just way too obvious that (despite tortured discussions such as you referenced) it might not work everywhere, or forever. Commented May 19, 2022 at 23:21
  • 1
    I love this answer, and it's really clever, but I don't think it's correct. POSIX specifies for awk's srand: "Set the seed value for rand to expr or use the time of day if expr is omitted. The previous seed value shall be returned." But it does not say what form of the "time of day" is "used", and seems to allow for the implementation to chose something like a hash of the epoch timestamp, just the HH:MM:SS part, a timestamp against a different epoch, etc. Commented May 20, 2022 at 14:46
  • 2
    @StéphaneChazelas: Oh wow, excellent! It does seem to codify that it's only 32-bit though, making this approach EOL'd. Commented May 20, 2022 at 17:25