[Rpm-maint] [rpm-software-management/rpm] RFE: Convenient version comparison macro (#1217)
Miro Hrončok
notifications at github.com
Thu May 14 09:51:50 UTC 2020
So, here are couple examples. I haven't checked if they don't collide with existing syntax.
```spec
# int comparison, fallbacks to version comparison if at least one operand has nondigits?
%if %{php_version} < 5.6
# string comparison, produces incorrect results some time
%if "%{php_version}" < "5.6"
# single quotes (easy, but it doesn't actually scream *this is version comparison*)
%if '%{php_version}' < '5.6'
# backticks (easy, as above, but at least screams "I am special")
%if `%{php_version}` < `5.6`
# string prefixes (see Python f-strings, b-strings and r-strings; confusing to non-Python people)
%if v"%{php_version}" < v"5.6"
# square brackets (special enough, but screams "I am an array with 1 element" to me)
%if [%{php_version}] < [5.6]
# square brackets around the whole thing (why? screams "wtf")
%if [%{php_version} < 5.6]
# special %if like %ifarch (maybe too much?)
%ifver %{php_version} < 5.6
# a prefix without quotes (both confusing)
%if @%{php_version} < @5.6
%if $%{php_version} < $5.6
# a special macro (easy to understand a bit more complicated to write)
%if %{vercmp %{php_version} < 5.6}
# a special macro to mark the values as versions (a bit more complicated to write as well)
%if %{ver:%{php_version}} < %{ver:5.6}
# golging the above (a bit more complicated to read)
%if %{V:%{php_version}} < %{V:5.6}
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1217#issuecomment-628526414
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200514/08156b30/attachment.html>
More information about the Rpm-maint
mailing list