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:
This is similar to bug 344411. Backporting patch will fix it.
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 "?".
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.
Created attachment 474216 [details] Patch for RNG
Fixed in bash-3.2-27.el5
Bugfix verified on bash-3.2-29.el5 package on all supported architectures. $RANDOM value is now random also after usage of "-$RANDOM".
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.
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.
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.
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.
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