[Rpm-maint] [rpm-software-management/rpm] RFE: pass parametric macro options and arguments to Lua natively (#1092)

Panu Matilainen notifications at github.com
Tue Oct 6 14:02:55 UTC 2020


https://lua.programmingpedia.net/en/tutorial/4475/variadic-arguments applies, eg to walk through arguments:

> $ ./rpm --define "foo(..) %{lua: t = {...}; print('nargs '..rpm.expand('%{#}: ')); for i, v in ipairs(t) do print(i..':'..v..' '); end}" --eval "%foo 5 4 3 2 -z"
nargs 5: 1:5 2:4 3:3 4:2 5:-z 

The question mark(s) revolve around what to do with options when present in normal parametric macros. The current behavior is to pass them to Lua as arguments, and %{#} macro carries the number of non-option arguments so you can calculate how many option arguments there are.

> $ ./rpm --define "foo(z:) %{lua: t = {...}; print('nargs '..rpm.expand('%{#}: ')); for i, v in ipairs(t) do print(i..':'..v..' '); end}" --eval "%foo 5 4 3 2 -z7"
nargs 4: 1:-z7 2:5 3:4 4:3 5:2

Another possibility would be not passing options as arguments to Lua except when custom option processing is selected, which would *kinda* make sense, but also seems limiting.

-- 
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/1092#issuecomment-704290557
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20201006/1dcd0505/attachment.html>


More information about the Rpm-maint mailing list