[Rpm-maint] [rpm-software-management/rpm] %global expands twice (#1049)

Michael Schroeder notifications at github.com
Wed Feb 5 10:48:24 UTC 2020

Oh wow, I knew that %global expands right away when defining the macro, but I somehow didn't expect that it expands again when the macro is used:
$ rpm --eval '
> %define foo %%%%
> %global bar %%%%
> %foo percent, %bar percent'

%% percent, % percent
Is that documented anywhere?

Anyway, I'm pretty sure that changing this will break most packages that use %global instead of %define because some guidelines said so, but I'm wondering if we should add two new macros to make it easier to use %global in a safe way:
%{literal:%foo}       - expands to the unexpanded body, i.e. `%foo`
%{quotepercent:%foo}  - expands the body and then doubles all % chars, i.e. '%%%%'
(I do not like the name `quotepercent`, though)

With those macros, `%global foo %{literal:...}` would be exactly like %define but at global level, whereas `%global foo %{quotepercent:...}` would only expand at the macro definition.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200205/dfdeba71/attachment.html>

More information about the Rpm-maint mailing list