Loading a lua script

From: Robert <ro....at.web.de>
Date: Sun, 23 Jan 2011 19:11:21 +0100

Hi,

inspired by the change [1] in args.lua to the help text I wrote a
command line argument to use Textadept as a Lua interpreter. The
luatex interpreter has a switch like this and I thought something like
this would be useful, especially on Windows where it's not a one-liner
to install Lua.

In my init.lua:
local function luaonly(file)
  if not file then
    print('No script file given.')
    os.exit()
  end
  f, err = loadfile(file)
  if err then
    print(err)
  else
    pcall(f)
  end
  os.exit()
end
args.register('-l', '--luaonly', 1, luaonly, 'Load lua script and exit')

A script "test.lua" can now be run from the command line with
textadept --luaonly test.lua

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).

Robert

[1] http://code.google.com/p/textadept/source/detail?r=de4e9289af5f119c776a6063a2dfd270a44b38a7
Received on Sun 23 Jan 2011 - 13:11:21 EST

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