lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Monday, April 7, 2014, Enrico Colombini <erix@erix.it> wrote:
On 07/04/2014 0.01, Petite Abeille wrote:
In any case, one could always use, say, arg[ 0 ] in the main module
for the same effect.

I just did that in a program I am writing (not extensively checked, it works on my Windows system):

  -- tell 'require' to look first into the directory
  -- containing this script
  local maindir = string.match(arg[0], '(.-)[^\\/]+$')
  package.path = maindir .. '?.lua;' .. package.path

  -- load required modules
  loader = require('m_loader')
  compiler = require('m_compiler')
  streamer = require('m_astream')
  coder = require('m_codegen')
  writer = require('m_writer')

(I suppose package.cpath should be changed too if C modules are required)

--
  Enrico


Wasn't this default 5.1, until it was deamed a security risk?