diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-22 22:29:36 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-22 22:29:36 -0300 |
commit | 66b2816a2fd193eaf09f916efb0231aa7184db8a (patch) | |
tree | c2932b201b7c6dbd65c30185496d29f4df775b1b | |
parent | 8a970f4acde3bf727ca6f0348aabb0e5a2675feb (diff) | |
download | luarocks-66b2816a2fd193eaf09f916efb0231aa7184db8a.tar.gz luarocks-66b2816a2fd193eaf09f916efb0231aa7184db8a.tar.bz2 luarocks-66b2816a2fd193eaf09f916efb0231aa7184db8a.zip |
cfg: do not crash when arg is not available
Fixes #852.
-rw-r--r-- | src/luarocks/core/cfg.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 2606291c..7d4896b7 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -538,8 +538,8 @@ function cfg.init(lua_data, project_dir, warning) | |||
538 | 538 | ||
539 | local lua_version = lua_data.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) | 539 | local lua_version = lua_data.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) |
540 | local luajit_version = lua_data.luajit_version or hardcoded.LUAJIT_VERSION or (jit and jit.version:sub(8)) | 540 | local luajit_version = lua_data.luajit_version or hardcoded.LUAJIT_VERSION or (jit and jit.version:sub(8)) |
541 | local lua_interpreter = lua_data.lua_interpreter or hardcoded.LUA_INTERPRETER or (arg[-1] and arg[-1]:gsub(".*[\\/]", "")) or (is_windows and "lua.exe" or "lua") | 541 | local lua_interpreter = lua_data.lua_interpreter or hardcoded.LUA_INTERPRETER or (arg and arg[-1] and arg[-1]:gsub(".*[\\/]", "")) or (is_windows and "lua.exe" or "lua") |
542 | local lua_bindir = lua_data.lua_bindir or hardcoded.LUA_BINDIR or (arg[-1] and arg[-1]:gsub("[\\/][^\\/]+$", "")) | 542 | local lua_bindir = lua_data.lua_bindir or hardcoded.LUA_BINDIR or (arg and arg[-1] and arg[-1]:gsub("[\\/][^\\/]+$", "")) |
543 | local lua_incdir = lua_data.lua_incdir or hardcoded.LUA_INCDIR | 543 | local lua_incdir = lua_data.lua_incdir or hardcoded.LUA_INCDIR |
544 | local lua_libdir = lua_data.lua_libdir or hardcoded.LUA_LIBDIR | 544 | local lua_libdir = lua_data.lua_libdir or hardcoded.LUA_LIBDIR |
545 | local lua_dir = lua_data.lua_dir or hardcoded.LUA_DIR | 545 | local lua_dir = lua_data.lua_dir or hardcoded.LUA_DIR |
@@ -710,7 +710,7 @@ function cfg.init(lua_data, project_dir, warning) | |||
710 | defaults.rocks_provided, defaults.rocks_provided_3_0 = make_rocks_provided(lua_version, luajit_version) | 710 | defaults.rocks_provided, defaults.rocks_provided_3_0 = make_rocks_provided(lua_version, luajit_version) |
711 | use_defaults(cfg, defaults) | 711 | use_defaults(cfg, defaults) |
712 | 712 | ||
713 | cfg.variables.LUA = cfg.variables.LUA or cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter | 713 | cfg.variables.LUA = cfg.variables.LUA or (cfg.variables.LUA_BINDIR and cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter) |
714 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch | 714 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch |
715 | 715 | ||
716 | ---------------------------------------- | 716 | ---------------------------------------- |