Well, my first Redhat Bug! It seems that the -gt logic is broken in bash-2.05-8.2 (Redhat Enterprise 2.1 release) and bash-2.05b-29.0.3 (Redhat Enterprise 3.0 release).
Not much between the version numbers there really? It’s fixed in RHE3 by use of a “long long” data type, rather than just a long, as integers of the form YYYYMMDDHHMMSS (eg. 20041022113705) overflow a long it seems, hence the broken logic when comparing two numbers.
The workaround is, as I say in the bug, to simply use the string comparator (>) rather than -gt – but it’s a nasty little gotcha, and I’d hope that Redhat look at backporting the version of bash. We certainly had to scratch our heads a few times before we worked out what was going on.

Entries (RSS)