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

Re: funny subshell effect



On 10 March 2011 15:56, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 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.

Well, I know that part, what confused me was that I wasn't starting
any subshells. But it seems that globbing is performed after forking
to run an external command, and of course zsh doesn't bother to fork
if the command is builtin. Is there some reason I'm not thinking of
why it's like that?

-- 
Mikael Magnusson



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