Re: [textadept] Loading a lua script

From: mitchell <c....at.caladbolg.net>
Date: Wed, 16 Feb 2011 22:56:44 -0500 (EST)

Hi,

On Tue, 15 Feb 2011, Robert wrote:

> On Tue, Jan 25, 2011 at 10:40 PM, Robert <ro....at.web.de> wrote:
>> On Sun, Jan 23, 2011 at 8:04 PM, mitchell <c....at.caladbolg.net> wrote:
>> <snip>
>>>> A script "test.lua" can now be run from the command line with
>>>> textadept --luaonly test.lua
>>>
>>> Cool! This can be rather useful.
>>>
>>>> Does anyone know how I could sandbox this that Textadept's modules
>>>> would not be part of the script's environment? I read a bit about
>>>> sandboxing and setfenv but haven't found a simple way yet. If this is
>>>> possible one could also use Textadept instead of the external Lua
>>>> interpreter in the run commands (if there is no Lua installed).
>>>
>>> I'm not sure that setfenv would work. Other than the obvious '[table] =
>>> nil', I don't know how this would be done since most of the initial state is
>>> populated in C.
>>>
>>> mitchell
>>>
>> Putting this directly in core/args.lua, like
>>
>> if (arg[1] == '-l' or arg[1] == '--luaonly') then
>> �luaonly(arg[2])
>> end
>>
>> args.register('-l', '--luaonly', 1, function() end, 'Load lua script and exit')
>>
>> with local function luaonly as before there aren't that many things
>> loaded, so it would be less effort to delete them (or not necessary) -
>> plus starting the script here (before loading all other Textadept
>> modules) makes it feel as fast as using the standard Lua interpreter.
>>
>> Robert
>>
> How about the attached patch? If not for core I'd put it on the wiki.
> I changed the arg positions so that they make sense for an external
> script and removed
> gui and new_buffer. The rest seems not to be so dangerous.

While cute, I don't intend to put such a thing into core because ta is not
a Lua interpreter. That is what lua.exe is for :) It's rather painless to
install too.

The wiki is a good place for things like these. Thanks for sharing!

mitchell
Received on Wed 16 Feb 2011 - 22:56:44 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:59:12 EST