I wrote these snippets for version comparison and they are not in good quality but enough for me.
The following code is an implementation which compare arithmetically and alphabetically:
But I later found it cant return the correct result I expect for 1.0 and 1.0rc1. So, I decided to strip and made a simplified version, it will die hard when non-digits are supplied.
I think there is another quick way to compare, using sort -V. sort can sort version strings, too. You feed it with two lines of version strings, then see which is returned first. But, I dont think it covers all strange versioning schemes.
0 comments:
Post a Comment