Bug #1828
Comparison of strings containing versions
| Status: | Closed | Start date: | 12/19/2008 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | language | |||
| Target version: | 0.24.8 | |||
| Affected Puppet version: | 0.24.6 | Branch: | ||
| Keywords: | if language bug integer conversion | |||
| Votes: | 0 |
Description
As discussed on IRC:
class puppet-version-test {
if $puppetversion > "0.24.5" {
notify { "newer than 0.24.5.":
message => "We're newer than 0.24.5.",
}
}
if $puppetversion == "0.24.5" {
notify { "0.24.5":
message => "We're 0.24.5.",
}
}
if $puppetversion > "0.24.6" {
notify { "newer than 0.24.6.":
message => "We're newer than 0.24.6.",
}
}
if $puppetversion == "0.24.6" {
notify { "0.24.6":
message => "We're 0.24.6.",
}
}
if $puppetversion > "0.24.7" {
notify { "newer than 0.24.7.":
message => "We're newer than 0.24.7.",
}
}
if $puppetversion == "0.24.7" {
notify { "0.24.7":
message => "We're 0.24.7.",
}
}
if $puppetversion > "0.24.8" {
notify { "newer than 0.24.8.":
message => "We're newer than 0.24.8.",
}
}
if $puppetversion == "0.24.8" {
notify { "0.24.8":
message => "We're 0.24.8.",
}
}
notify { "puppetversion":
message => $puppetversion,
}
}
Which gives this output:
otice: We're 0.24.8. notice: //Node[default]/puppet-version-test/Notify[0.24.8]/message: defined 'message' as 'We're 0.24.8.' notice: We're 0.24.7. notice: //Node[default]/puppet-version-test/Notify[0.24.7]/message: defined 'message' as 'We're 0.24.7.' notice: We're 0.24.6. notice: //Node[default]/puppet-version-test/Notify[0.24.6]/message: defined 'message' as 'We're 0.24.6.' notice: We're 0.24.5. notice: //Node[default]/puppet-version-test/Notify[0.24.5]/message: defined 'message' as 'We're 0.24.5.' notice: 0.24.7 notice: //Node[default]/puppet-version-test/Notify[puppetversion]/message: defined 'message' as '0.24.7'
According to masterzen, the string gets converted to a float, which leads to an invalid float which compares 0 to 0.
History
Updated by Brice Figureau about 3 years ago
- Category changed from unknown to language
- Status changed from Unreviewed to In Topic Branch Pending Review
- Assignee changed from Brice Figureau to James Turnbull
- % Done changed from 0 to 100
- 3 changed from Unknown to Trivial
- Keywords set to if language bug integer conversion
tstoop wrote:
According to masterzen, the string gets converted to a float, which leads to an invalid float which compares 0 to 0.
Actually, only the first 0 was converted to integer (and the rest ignored by ruby conversion routine), because the various regexs that checks for hex, octal or integer were not strict enough and buggy.
Fix & tests available in tickets/0.24.x/1828 in my github repository (masterzen/puppet): http://github.com/masterzen/puppet/tree/tickets/0.24.x/1828
Updated by James Turnbull almost 3 years ago
- Status changed from In Topic Branch Pending Review to Closed
- Target version set to 0.24.8
Pushed in commit:73a0757b559d7e4fbd1da43bbcf4e60fd9155896 in branch 0.24.x