lua-users home
lua-l archive

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


On Sat, Aug 6, 2011 at 9:28 AM, Frank Meier-Dörnberg <frank@md-web.de> wrote:
> Am 06.08.2011 06:22, schrieb Brian Maher:
> ...
>>
>>  [1] Set the LUA_ROOT global variable to dirname(dirname(argv[0])) in
>> pmain() of lua.c
>>
>>  [2] Modify setpath() in loadlib.c so it replaces the special "..."
>> token with the LUA_ROOT global variable and if that fails, fall-back
>> to the LUA_ROOT compile time define.
>
> ...
>
> I'm not sure about the semantic yet, but should that not handled similar to
> what is done for windows in (Lua 5.1) luaconf.h?
> <cite>
> /*
> ** In Windows, any exclamation mark ('!') in the path is replaced by the
> ** path of the directory of the executable file of the current process.
> */
> <\cite>
>
> i.e.: "!" instead of "...", correct?
>
> Please excuse my question (I'm a windows user), why these thing is solved
> differently at all?
The difference between ".." and "!" is that the exclamation mark
executable location where the ".." is relative path in regards to the
current directory. It makes more sense to use the "!" in a portable
Lua installation. However this is only available on WIndows. In Lua[1]
distributed with LuaDist there is a (optional) patch for loadlib[2]
that brings this notation to other platforms. It is not however easy
to find the path of the executable consistently between various
systems hence the ugly fallback. This works as on Windows on all
systems I have access to.

pd

[1] https://github.com/LuaDist/lua
[2] https://github.com/LuaDist/lua/blob/master/src/loadlib_rel.c#L68