lua-users home
lua-l archive

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


Michal Kolodziejczyk wrote:
There are similar problems in unix-based OSes, and are solved by
environment variables ($HOME, $PATH, etc).

So you can try something like this:

/etc/rc.local:
LUA_INIT=/etc/luaenv.lua

/etc/luaenv.lua:
package.path=os.getenv('HOME')..'/lua;'..package.path
-- or:
-- package.path='/opt/common/lua/'..os.getenv('USER')..';'..package.path

and ask every user to put their modules in their home directories, in
~/lua or /opt/common/lua/<username>.

There seems to be misunderstanding (probably because I was using the word 'user' in a confusing way). What happens in fact is:

-- assuming the program directory is somepath/plugin

-- programmer John adds a bunch of his scripts and modules, that must be installed in a subtree somepath/plugin/John. His initialization script adds somepath/plugin/John/?.lua in front of package.path, and adds a bunch of menu items to the main program's menu.

-- programmer Ann adds a bunch of her scripts and modules, that must be installed in a subtree somepath/plugin/Ann. Her initialization script adds somepath/plugin/Ann/?.lua in front of (already modified) package.path, and adds another bunch of menu items to the main program's menu.

-- there can be quite a few "programmers"

-- user Jim installs: the main program + John's scripts + Ann's scripts

-- user Jim can at any moment invoke *any* script, via the program menu or a hot key

-- in the invoked script, require 'somelib' could access a wrong module, if both John and Ann happened to have a module named 'somelib'.

Hopefully, it is more clear now. Sorry for verbosity.

--
Shmuel