On 6/18/19 2:09 PM, Florian Weimer wrote:
* Panu Matilainen:
> On 6/18/19 10:15 AM, Florian Weimer wrote:
>> * Panu Matilainen:
>>
>>> On 6/17/19 4:45 PM, Florian Weimer wrote:
>>>> * Panu Matilainen:
>>>>
>>>>> On 6/13/19 12:54 PM, Miroslav Suchý wrote:
>>>>>> This is wrong (not sure if the culprit)
>>>>>>
>>>>>> %endif %{__with_rebar3}
>>>>>>
>>>>>> I would rewrite it to:
>>>>>>
>>>>>> %endif # __with_rebar3
>>>>>
>>>>> Actually both are wrong, and rpm >= 4.15 will complain (unlike
old
>>>>> versions). Rpm only supports comments at beginning of line, and this
>>>>> only ever worked by accident.
>>>>
>>>> Would it be possible to bring back the ability to comment on %endif
>>>> lines at least? It's nice to have a comment there if the condition
is a
>>>> screen or two away.
>>>
>>> Nothing prevents you from putting the comment on the line above:
>>>
>>> # __with_rebar3
>>> %endif
>>
>> This doesn't follow the usual convention for such comments.
>
> Yeah, but then rpm never officially supported the "usual
> convention". It was just another spec parser quirk that they got
> through until now (and again, it's only a warning still)
Still it seemed rather useful.
Can you put a macro invocation after %endif, on the same line? If yes,
we could have macro there that expands to nothing.
You can, and that's pretty much the reason for this warning because it's
*not* what you'd expect [*]. For example, %define and %global expand to
nothing... and any text following %else or %endif gets treated as part
of the preceeding block, ie text following %else on the same line gets
expanded when the %if-condition is true. Yes, you read that right.
So if you have
%if 1 == 1
echo moo
%else # %define aaa bbb
echo foo
%endif # %define aaa ccc
...the value of aaa macro is actually bbb after parsing this. Those
%define's could also be there without the comment marks and behave the
same deed.
So the new warning has to look at the line *before* expanding it, so a
macro wont help with that. Rpm could of course specifically handle #
-comments there, but for consistency it should allow free # -comments
everywhere then.
[*] For the full horror, see
https://github.com/rpm-software-management/rpm/pull/625. And if you read
that, you'll find that I'm also a bit torn on the issue of losing those
comments after %endif.
- Panu -