Bug 136688

Summary: bash -gt logic broken comparing large integers
Product: Red Hat Enterprise Linux 2.1 Reporter: Richard Leyton <richard.leyton>
Component: bashAssignee: Pete Graner <pgraner>
Status: CLOSED CURRENTRELEASE QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 2.05b-29.0.3 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-08-29 18:52:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reproduction of gt bug
none
Reproduction of gt bug none

Description Richard Leyton 2004-10-21 17:59:34 UTC
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):
bash-2.05-8.2

How reproducible:
Always

Steps to Reproduce:
Create a script:

#!/bin/bash
v1=20041021183908
v2=20041021183406

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

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 18:25:02 UTC
The obvious work-around is to use the ">" operator, which we're doing
right now.

Comment 2 Richard Leyton 2004-10-21 18:32:25 UTC
Created attachment 105601 [details]
Reproduction of gt bug

Comment 3 Richard Leyton 2004-10-21 18:35:18 UTC
Created attachment 105602 [details]
Reproduction of gt bug

Reproduction script

Comment 4 Pete Graner 2007-08-29 18:52:09 UTC
Fixed in newer versions of bash. Closing.