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

Re: A strange function behaviour in random password generator



On 6 December 2010 14:15,  <nix@xxxxxxxxxxxxxxxx> wrote:
> Hi, I have just coded a random password generator. It works good but one
> might want to show me how to do it with rand48() as itæ output is
> strange.
>
> The problem:
>
> ./random_pass.sh
> iNkiuG
> iNkiuG6K
>
> 6 first chars are the same for both passwords.

> [...]

> pos=$((RANDOM%$seeds_count+1))
> MY_RCON=$(random 6)
> MY_PASS=$(random 8)

If you access $RANDOM in a subshell, the parent shell doesn't know
about it, and next time it forks a subshell the state will be
identical.

-- 
Mikael Magnusson



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