http://bugzilla.novell.com/show_bug.cgi?id=559877 http://bugzilla.novell.com/show_bug.cgi?id=559877#c0 Summary: $RANDOM variable doesn't work as expected in scripts Classification: openSUSE Product: openSUSE 11.2 Version: Final Platform: x86-64 OS/Version: openSUSE 11.2 Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: tim@ehlers.info QAContact: qa@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.5) Gecko/20091103 SUSE/3.5.5-3.1 Firefox/3.5.5 There seems to be a bug in bash when using bash in scripts. In interactive Shell I get 2 one-digit ([1-9]) random numbers when typing: # for i in 1 2; do let "number = $RANDOM % 9 + 1"; echo $number; done 9 3 # for i in 1 2; do let "number = $RANDOM % 9 + 1"; echo $number; done 2 4 When writing this in a script and executing it. I always get the same numbers: --- cat /usr/local/bin/bash-random-check #!/bin/bash for i in 1 2; do let "number = $RANDOM % 9 + 1"; echo $number; done --- # /usr/local/bin/bash-random-check 2 6 # /usr/local/bin/bash-random-check 2 6 Reproducible: Always Steps to Reproduce: 1. for i in 1 2; do let "number = $RANDOM % 9 + 1"; echo $number; done 2. echo -e '#!/bin/bash\n\nfor i in 1 2; do let "number = $RANDOM % 9 + 1"; echo $number; done' > bash-random-check 3. chmod a+x bash-random-check 4. ./bash-random-check Actual Results: static numbers Expected Results: random numbers -- Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.