[texworks] Lua scripting

Stefan Löffler st.loeffler at gmail.com
Wed Jun 10 15:22:29 CEST 2009


Hi,

Jérome Laurens schrieb:
> Here are some info I gathered here and there
>
> - to execute a script in a void environment:
>
> local myFunction = loadfile("myscript.lua"); -- You may wish to check
> for errors
> setfenv(myFunction, {});
> myFunction(); -- You may wish to pcall this
>
> a void environment is sometimes too restrictive.
>
> - to restrict some lua functions, for example restrict the write_to
> function to only checked paths:
>
> unsafe_writeto = writeto
> writeto = function (filename)
> if checkfilename(filename) then
> %unsafe_writeto(filename) -- do the "real" open
> else error("cannot open " .. filename)
> end
> end
> unsafe_writeto = nil -- no more accesses after this point

Thanks, that's a good start. I'd have to transcode it to the Lua C Api,
but that shouldn't be too difficult. And since the scripts are run from
only one function I'd only have to code it once.

Are there any other critical functions? Like command execution, or
something? Network/internet access?

For now I'm awaiting further feedback on the existing patch, though. If
the feedback is positive and Jonathan commits the patch I'll dig further
into this. Until then I prefer not to start a pseudo-branch with
countless branches ;).

-Stefan


More information about the texworks mailing list