[Rpm-maint] [rpm-software-management/rpm] Auto-print returned values from Lua macros (PR #1837)

Michael Schroeder notifications at github.com
Fri Nov 19 09:27:43 UTC 2021


@mlschroe commented on this pull request.



>  	rpmlog(RPMLOG_ERR, _("lua script failed: %s\n"),
 		 lua_tostring(L, -1));
 	lua_pop(L, 1);
 	goto exit;
     }
+
+    int nret = lua_gettop(L) - otop;
+    if (nret > 0 && lua->printbuf)
+	rpm_print(L);

My suggestion was something like (untested):
```
lua_getglobal(L, "print");
lua_insert(L, otop);
if (lua_pcall(L, nret, 0, 0) != 0) {
        rpmlog(RPMLOG_ERR, result print failed: %s\n"),
                 lua_tostring(L, -1));
        lua_pop(L, 1);
}
```

-- 
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/pull/1837#discussion_r753011288
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20211119/8b50d620/attachment.html>


More information about the Rpm-maint mailing list