I am not able to understand why zsh is generating the same random value when calling a subshell.
Consider the following code:
$ cat script.sh
#!/bin/zsh
checkFieldConvergence () {
echo $RANDOM
echo $RANDOM
}
echo $(checkFieldConvergence)
echo $(checkFieldConvergence)
echo $(checkFieldConvergence)
checkFieldConvergence
checkFieldConvergence
checkFieldConvergence
$ ./script.sh
4049 24768
4049 24768
4049 24768
4049
24768
20764
3330
17114
1195
whereas the same with bash
gives
$ cat script.sh
#!/bin/bash
checkFieldConvergence () {
echo $RANDOM
echo $RANDOM
}
echo $(checkFieldConvergence)
echo $(checkFieldConvergence)
echo $(checkFieldConvergence)
checkFieldConvergence
checkFieldConvergence
checkFieldConvergence
$ ./script.sh
12274 28155
27609 10269
14100 14662
6945
17897
20354
29817
14495
27552
Aucun commentaire:
Enregistrer un commentaire