Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: random once but not twice
On Sun, Nov 12, 2017 at 4:15 PM, Emanuel Berg <moasen@xxxxxxxx> wrote:
>
> Works! Only I don't understand this syntax.
> What does it do?
>
> seed=$(<$file)
RTM:
A command enclosed in parentheses preceded by a dollar sign, like
`$(...)', or quoted with grave accents, like ``...`', is replaced with
its standard output, with any trailing newlines deleted. If the
substitution is not enclosed in double quotes, the output is broken
into words using the IFS parameter. The substitution `$(cat FOO)' may
be replaced by the equivalent but faster `$(<FOO)'. In either case,
if the option GLOB_SUBST is set, the output is eligible for filename
generation.
> and
>
> print $seed >$file
>
> I suppose is some intentional circular
> short-circuit to generate gibberish data?
The comment in the function explains this:
# This version is slow but works around the fact
# that the random number seed doesn't propagate
# back from a subshell by storing the seed in
# a file.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author