[Rpm-maint] [rpm-software-management/rpm] Accessing macro parameter from lua fails with "attempt to index a nil value (global 'opt')" (Issue #2446)
Ralf Habacker
notifications at github.com
Wed Mar 22 15:04:54 UTC 2023
The documentation at https://github.com/rpm-software-management/rpm/blob/master/docs/manual/lua.md mentions how to get macro options as
```
%foo(a:b) %{lua:
if opt.b then
...
```
but this does not work on openSUSE Leap 15.4 with rpm with version:
```
rpm --version
RPM version 4.14.3
```
Running such a macro returns this error:
```
error: lua script failed: [string "<lua>"]:2: attempt to index a nil value (global 'opt')
```
# How to reproduce
1. Paste the following macro, mentioned in the documentation, into a file:
```
cat << EOF > test.macros
%foo(a:b) %{lua:
if opt.b then
print('do b')
else
print('or not')
end
if opt.a == 's' then
print('do s')
end
if #arg == 0 then
print('no arguments :(')
else
for i = 1, #arg do
print(arg[i])
end
end
}
EOF
```
2. then run
```
$ rpm --eval='%{load:test.macros} %foo -axxx=yyy -b dsdsd'
error: lua script failed: [string "<lua>"]:2: attempt to index a nil value (global 'opt')
```
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/2446
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/issues/2446 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20230322/65f135e1/attachment.html>
More information about the Rpm-maint
mailing list