From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: funny subshell effect
Date: Thu, 10 Mar 2011 06:56:53 -0800 [thread overview]
Message-ID: <110310065653.ZM15150@torch.brasslantern.com> (raw)
In-Reply-To: <AANLkTi=VUkvqOxo+OANG2AVYko-Zbq7LwLQoF68fbLev@mail.gmail.com>
On Mar 10, 12:18am, Mikael Magnusson wrote:
} Subject: funny subshell effect
}
} % repeat 3; do command echo .(e:REPLY=\$RANDOM:); done
} 5801
} 5801
} 5801
}
} Is this something that must be so?
Yep, it's intentional. Read the manual:
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 between subshell invocations.
Above that, "The random number generator can be seeded by assigning a
numeric value to RANDOM."
% for i in {1..3}; do command echo .(e:RANDOM=$i\;REPLY=\$RANDOM:); done
17767
6138
20026
If you're not generating more than one number per second, a good way
to see the generator is with $SECONDS. Or if your system supports a
higher granularity clock, something like
typeset -F SECONDS
repeat 3; do
command echo .(e:'RANDOM=$((SECONDS*1000));REPLY=$RANDOM':);
done
Consequently, Phil ... your approach may be reasonable, but we don't
want to apply it. :-)
next prev parent reply other threads:[~2011-03-10 14:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-09 23:18 Mikael Magnusson
2011-03-10 0:29 ` Phil Pennock
2011-03-10 14:56 ` Bart Schaefer [this message]
2011-03-10 15:11 ` Mikael Magnusson
2011-03-17 3:44 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=110310065653.ZM15150@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).