lua-users home
lua-l archive

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

Hi all!

I played a bit with the new 5.2.0 interpreter and stumbled on a possible issue.

According to the refman the -E option makes the interpreter ignore all environment variables altogether. In particular LUA_PATH and LUA_CPATH, so that package.path and package.cpath are reset to whatever
is their predefined value in luaconf.h

The problem is that on Windows (XP SP2) package.path defaults to:


where the "!" character should be interpreted by Windows as the "path of the directory of the executable file of the current process" (according to the comments in luaconf.h - lines 89-90).

The problem is that this doesn't seem to work. If I put this file:

-- test.lua
print "HELLO"

inside the bin/lua subdir of my lua 5.2.0 installation dir and then type the following on the command line:

lua -E -e"require'test'"

I get the following exception:

G:\root\main\core\Lua\tools\..\app\Lua52\bin\lua.exe: (command line):1: module 'test' not found:
        no field package.preload['test']
        no file '!\lua\test.lua'
        no file '!\lua\test\init.lua'
        no file '!\test.lua'
        no file '!\test\init.lua'
        no file '.\test.lua'
        no file '!\test.dll'
        no file '!\loadall.dll'
        no file '.\test.dll'
stack traceback:
        [C]: in function 'require'
        (command line):1: in main chunk
        [C]: in ?


lua -e"require'test'"

prints "HELLO" as expected.

It seems that the "!" doesn't do what is expected to do.

BTW: I was surprised to read that comment about "!" in luaconf.h. I didn't know such a feature existed. I don't think it is exposed by the Windows command processor (in batch files you use %~dp0 instead). Maybe some OS API? I've an old .hlp file with Win32 API documentation, but I didn't find anything about it (I admit I'm not an expert of Win32 API, so I might have overlooked it).

Any reference to MS API documentation on that topic is appreciated.

-- Lorenzo