[Rpm-ecosystem] Fwd: [Rpm-maint] Fixing macro scoping

Panu Matilainen pmatilai at laiskiainen.org
Fri Feb 3 14:21:12 UTC 2017

On 02/03/2017 03:37 PM, Neal Gompa wrote:
> On Fri, Feb 3, 2017 at 7:35 AM, Panu Matilainen
> <pmatilai at laiskiainen.org> wrote:
>> On 02/03/2017 02:22 PM, Neal Gompa wrote:
>> [...snip...]
>>> Sorry if I sound stupid about this, but I've read this email at least
>>> four times now, and I'm still not quite sure what you're trying to
>>> describe...
>> Right, quite possibly the question got lost in the rpm internals
>> mumble-jungle.
>> So forget the all the technical mumbling about scoping levels etc for now.
>> What would you expect the following snippet to output (full reproducer spec
>> is at https://bugzilla.redhat.com/show_bug.cgi?id=552944)?
>> %{!?foo: %define foo bar}
>> %define dofoo() true
>> echo 1: %{foo}
>> %dofoo
>> echo 2: %{foo}
> I would expect that would expand each time. My expectation is that it
> should evaluate and expand correctly on each invocation.

Well, define "correct". That is the question really :D
What rpm currently does is obviously just totally broken, but there are 
at least two or three different, entirely plausible interpretations.

I guess what you mean is you expect both echos to output "bar"?

The other interpretation, which rpm takes (but the implementation is 
flawed) is that %{} forms a scope of its own, just like curly braces do 
in C, and %define'd macros are local to the scope they were defined in 
so the echo's would output literal "%{foo}" (or error out, but that's 
yet another side-track I'd rather not get on right now)

I can easily live with either option assuming correct implementation, 
but I'm done encountering this stupid bug year after year after year 
when the next generation of packagers hits it. Lets just say that in a 
this kind of "minilanguage", I'd probably intuitively expect the less 
complex scoping. Meaning those echo's would evaluate to "bar".

	- Panu -

More information about the Rpm-ecosystem mailing list