Bugzilla will be upgraded to version 5.0 on December 2, 2018. The outage period for the upgrade will start at 0:00 UTC and have a duration of 12 hours
Bug 136688 - bash -gt logic broken comparing large integers
bash -gt logic broken comparing large integers
Product: Red Hat Enterprise Linux 2.1
Classification: Red Hat
Component: bash (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Pete Graner
Ben Levenson
Depends On:
  Show dependency treegraph
Reported: 2004-10-21 13:59 EDT by Richard Leyton
Modified: 2007-11-30 17:06 EST (History)
0 users

See Also:
Fixed In Version: 2.05b-29.0.3
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-08-29 14:52:09 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Reproduction of gt bug (172 bytes, text/plain)
2004-10-21 14:32 EDT, Richard Leyton
no flags Details
Reproduction of gt bug (174 bytes, text/plain)
2004-10-21 14:35 EDT, Richard Leyton
no flags Details

  None (edit)
Description Richard Leyton 2004-10-21 13:59:34 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3)
Gecko/20040913 Firefox/0.10

Description of problem:
bash incorrectly returns a false boolean value when comparing two long
integers (YYYYMMDDHHMMSS), specifically:

if [ 20041021183908 -gt 20041021183406 ]

returns false when it should return true

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
Create a script:


if [ $v1 -gt $v2 ]
  echo "$v1 is greater than $v2"
  echo "$v1 is less than $v2"

Run it!

Actual Results:  Output of script reads

20041021183908 is less than 20041021183406

Which is incorrect.

Expected Results:  It should read:

20041021183908 is greater than 20041021183406

Additional info:

Works fine on RHE3 (bash-2.05b-29.0.3)
Comment 1 Richard Leyton 2004-10-21 14:25:02 EDT
The obvious work-around is to use the ">" operator, which we're doing
right now.
Comment 2 Richard Leyton 2004-10-21 14:32:25 EDT
Created attachment 105601 [details]
Reproduction of gt bug
Comment 3 Richard Leyton 2004-10-21 14:35:18 EDT
Created attachment 105602 [details]
Reproduction of gt bug

Reproduction script
Comment 4 Pete Graner 2007-08-29 14:52:09 EDT
Fixed in newer versions of bash. Closing.

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