On 09/02/15 19:15, Assaf Gordon wrote: > Hello Pádraig, > > On 02/09/2015 12:22 PM, Pádraig Brady wrote: > <...> >> No counter arguments, which is surprising. > > For me, > your 'openssl' trick to generate reproducible (not so) random data was good > enough - perhaps if it's documented it will suffice? > >> Anyway personally I prefer the --random-seed option >> as it's neater, has less deps, and is about 10% faster even with hardware >> assist. >> >> As for the --random-seed interface. >> Should we be supplying a string rather than an int? >> At least we need to cater for endianness issues with an int, >> but a string might be easier to use. >> > > I do like it as well, but I'm biased... > > If we decide to continue with '--random-seed', I can work on improved patch > to implement that.
Thanks for the feedback. If this was often used we might consider the new option, however given the relatively infrequent use, let's err on the side of more documentation, and less options. The attached patch documents this. thanks, Pádraig.
From 4a2dca7469e8fc2563255fccd789c52b8feb0892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com> Date: Mon, 9 Feb 2015 20:58:47 +0000 Subject: [PATCH] doc: give an example of using a seed for random operations * doc/coreutils.texi (Random sources): Give an example using openssl, generating a reproducible arbitrary amount of randomly distributed data, given a seed value. --- doc/coreutils.texi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 87fb3dc..040f952 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -1240,6 +1240,21 @@ operating system. To reproduce the results of an earlier invocation of a command, you can save some random data into a file and then use that file as the random source in earlier and later invocations of the command. +@cindex random seed +Rather than depending on a file, one can generate a reproducible +arbitrary amount of pseudo-random data given a seed value, using +for example: + +@example +get_random() +@{ + seed="$1" + openssl enc -aes-256-ctr -pass pass:"$seed" -nosalt \ + </dev/zero 2>/dev/null +@} + +shuf -i1-100 --random-source=<(get_random 42) +@end example @node Target directory @section Target directory -- 2.1.0