lua-users home
lua-l archive

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


I came across this situation that I deem to be a bug in Lua 5.1. I get
exclamation marks replaced in LUA_PATH. This appears to be a
documented feature as luaconf.h is explicit about this:

/*
** In Windows, any exclamation mark ('!') in the path is replaced by the
** path of the directory of the executable file of the current process.
*/

However the problem is that an exclamation mark is a legitimate part
of a path and in my case it's not at the beginning of the path and I
couldn't find any way to disable this behavior.

When I run this:

SET LUA_PATH=/Lua/!me/zbs/lualibs/?/?.lua
bin\lua -e "require'foo'"

I get this error message:

bin\lua: (command line):1: module 'foo' not found:
        no field package.preload['foo']
        no file '/Lua/D:\Lua\!an\zbs\binme/zbs/lualibs/foo/foo.lua'

Notice that the exclamation mark in the path gets replaced (as
documented). You can dismiss it as the case of "when I do this it
hurts; don't do it", but it's not a hypothetical case; I got this
error message from one of my users.

I'd like to know if there is a way to avoid this behavior (or a
workaround) other than recompiling lua with this turned off.
Ideally I think this needs to be fixed with '!' only replaced if it's
at the beginning of the path.

Paul.