Bug 492908 - $RANDOM value remains the same
$RANDOM value remains the same
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: bash (Show other bugs)
5.3
All Linux
low Severity medium
: rc
: ---
Assigned To: Roman Rakus
BaseOS QE
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-03-30 13:08 EDT by Jaroslav Kortus
Modified: 2014-01-12 19:08 EST (History)
4 users (show)

See Also:
Fixed In Version: bash-3.2-27.el5
Doc Type: Bug Fix
Doc Text:
The $RANDOM variable in Bash carried over values from a previous execution for later jobs. This is fixed and the $RANDOM variable generates a new random number for each use.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-07-21 06:38:30 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch for RNG (1.52 KB, patch)
2011-01-19 03:08 EST, Roman Rakus
no flags Details | Diff

  None (edit)
Description Jaroslav Kortus 2009-03-30 13:08:42 EDT
Description of problem:
bash $RANDOM value remains the same after first usage with "-$RANDOM"

Version-Release number of selected component (if applicable):
bash-3.2-24.el5
GNU bash, version 3.2.25(1)-release (ia64-redhat-linux-gnu)

How reproducible:
100%

Steps to Reproduce:
1. for i in 1 2 3; do echo $RANDOM >> /tmp/random.txt& sleep 1; done
2. cat /tmp/random.txt (3 different numbers)
3. echo -$RANDOM
4. for i in 1 2 3; do echo $RANDOM >> /tmp/random.txt& sleep 1; done
5. cat /tmp/random.txt (3 different numbers from 1st run, 3 times one number from the 2nd one)
  
Actual results:
$RANDOM value is the same for every background command invocation 

Expected results:
$RANDOM value should be random each time

Additional info:
Comment 1 Roman Rakus 2009-03-31 09:50:36 EDT
This is similar to bug 344411. Backporting patch will fix it.
Comment 2 RHEL Product and Program Management 2009-11-06 13:58:57 EST
This request was evaluated by Red Hat Product Management for
inclusion, but this component is not scheduled to be updated in
the current Red Hat Enterprise Linux release. If you would like
this request to be reviewed for the next minor release, ask your
support representative to set the next rhel-x.y flag to "?".
Comment 4 RHEL Product and Program Management 2010-08-09 15:06:17 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.
Comment 5 Roman Rakus 2011-01-19 03:08:13 EST
Created attachment 474216 [details]
Patch for RNG
Comment 6 Roman Rakus 2011-02-21 11:38:22 EST
Fixed in bash-3.2-27.el5
Comment 8 Branislav Náter 2011-04-15 07:04:26 EDT
Bugfix verified on bash-3.2-29.el5 package on all supported architectures.

$RANDOM value is now random also after usage of "-$RANDOM".
Comment 9 Misha H. Ali 2011-04-20 05:02:07 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
The $RANDOM variable in Bash retained the number during jobs executed in the background. This is now fixed to ensure that the $RANDOM variable always generates a new random number.
Comment 10 Misha H. Ali 2011-04-20 05:37:57 EDT
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-The $RANDOM variable in Bash retained the number during jobs executed in the background. This is now fixed to ensure that the $RANDOM variable always generates a new random number.+The $RANDOM variable in Bash retained the value from a previous execution for later jobs that executed in the background. This is now fixed to ensure that the $RANDOM variable always generates a new random number.
Comment 11 Misha H. Ali 2011-04-20 20:13:14 EDT
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-The $RANDOM variable in Bash retained the value from a previous execution for later jobs that executed in the background. This is now fixed to ensure that the $RANDOM variable always generates a new random number.+The $RANDOM variable in Bash carried over the last generated value from a previous execution for later jobs that executed in the background. This is now fixed to ensure that the $RANDOM variable contains a new random number for each use.
Comment 12 Misha H. Ali 2011-05-03 21:35:06 EDT
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-The $RANDOM variable in Bash carried over the last generated value from a previous execution for later jobs that executed in the background. This is now fixed to ensure that the $RANDOM variable contains a new random number for each use.+The $RANDOM variable in Bash carried over values from a previous execution for later jobs. This is fixed and the $RANDOM variable generates a new random number for each use.
Comment 13 errata-xmlrpc 2011-07-21 06:38:30 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-1073.html

Note You need to log in before you can comment on or make changes to this bug.