What is the status and USP of the Lua rex extension?

Tim Landscheidt tim at tim-landscheidt.de
Sat Jan 5 06:38:29 UTC 2019


Hi,

with Fedora 28's RPM 4.14.2.1, I was looking at
http://rpm.org/user_doc/lua.html to mangle some strings.  It
took some experimentation to find that the actually working
syntax is:

| [tim at passepartout ~]$ rpm --eval '%{lua: local re = rex.newPOSIX("abc"); if re:match("abcdef") then print("Matched") else print("Not matched"); end}'
| Matched
| [tim at passepartout ~]$ rpm --eval '%{lua: local re = rex.newPOSIX("abc"); if re:match("acdef") then print("Matched") else print("Not matched"); end}'
| Not matched
| [tim at passepartout ~]$

However, taking http://math2.org/luasearch/rex.html as ref-
erence, there does not seem to be a way to access more use-
ful functions like rex.sub(), nor do PCRE regular expres-
sions seem to be available ("attempt to call a nil value
(field 'newPCRE')").

Even more confusing, Lua's internal string module seems to
provide most of what is needed (with a slightly different
syntax):

| [tim at passepartout ~]$ rpm --eval '%{lua: print(string.match("abcdef", "abc"));}'
| abc
| [tim at passepartout ~]$

So what is the status of and advantage to use the rex exten-
sion over the internal string module?  In Fedora's spec
files, rex does not seem to be used once, but string quite a
bit.

Tim


More information about the Rpm-list mailing list