Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

problems with RANDOM in subshells



One can work around the problem described below by doing

: $RANDOM ; (echo $RANDOM) | cat

Should the random-seeding behavior be changed for subshells?

----- Forwarded message from Falk Hueffner <falk@xxxxxxxxxx> -----

For each subshell, $RANDOM gets initialized to the same value, which
leads to the same sequence of random numbers.  This makes
e. g. playlist shuffling functions way boring, and is generally not
what one would expect.

falk@borkum:~% (echo $RANDOM) | cat
12042
falk@borkum:~% (echo $RANDOM) | cat
12042
falk@borkum:~% (echo $RANDOM) | cat
12042

	Falk

-- System Information
Debian Release: 3.0
Architecture: alpha
Kernel: Linux borkum 2.4.16 #1 Sat Dec 1 23:02:59 CET 2001 alpha
Locale: LANG=C, LC_CTYPE=de_DE

Versions of packages zsh depends on:
ii  libc6.1                  2.2.4-7         GNU C Library: Shared libraries an
ii  libcap1                  1:1.10-12       support for getting/setting POSIX.
ii  libncurses5              5.2.20020112a-2 Shared libraries for terminal hand


----- End forwarded message -----



Messages sorted by: Reverse Date, Date, Thread, Author