diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-13 19:46:03 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-13 22:27:17 -0300 |
| commit | 312d7f495a1c187ce988d6e19a50c19328c11ed6 (patch) | |
| tree | 3a1479043398658219b35b704538619602633244 /src | |
| parent | e9156c8ab6bc8b7f4c0e9d2e706131bc89bec57e (diff) | |
| download | luarocks-312d7f495a1c187ce988d6e19a50c19328c11ed6.tar.gz luarocks-312d7f495a1c187ce988d6e19a50c19328c11ed6.tar.bz2 luarocks-312d7f495a1c187ce988d6e19a50c19328c11ed6.zip | |
fix detection of Lua path based on arg variable
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/core/cfg.lua | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 48aff4d8..0c79fc63 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
| @@ -504,6 +504,19 @@ local function use_defaults(cfg, defaults) | |||
| 504 | end | 504 | end |
| 505 | end | 505 | end |
| 506 | 506 | ||
| 507 | local function get_first_arg() | ||
| 508 | if not arg then | ||
| 509 | return | ||
| 510 | end | ||
| 511 | local first_arg = arg[0] | ||
| 512 | local i = -1 | ||
| 513 | while arg[i] do | ||
| 514 | first_arg = arg[i] | ||
| 515 | i = i -1 | ||
| 516 | end | ||
| 517 | return first_arg | ||
| 518 | end | ||
| 519 | |||
| 507 | -------------------------------------------------------------------------------- | 520 | -------------------------------------------------------------------------------- |
| 508 | 521 | ||
| 509 | local cfg = {} | 522 | local cfg = {} |
| @@ -547,13 +560,15 @@ function cfg.init(detected, warning) | |||
| 547 | end | 560 | end |
| 548 | 561 | ||
| 549 | -- Use detected values as defaults, overridable via config files or CLI args | 562 | -- Use detected values as defaults, overridable via config files or CLI args |
| 563 | |||
| 564 | local first_arg = get_first_arg() | ||
| 550 | 565 | ||
| 551 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) | 566 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) |
| 552 | cfg.lua_interpreter = detected.lua_interpreter or hardcoded.LUA_INTERPRETER or (arg and arg[-1] and arg[-1]:gsub(".*[\\/]", "")) or (is_windows and "lua.exe" or "lua") | 567 | cfg.lua_interpreter = detected.lua_interpreter or hardcoded.LUA_INTERPRETER or (first_arg and first_arg:gsub(".*[\\/]", "")) or (is_windows and "lua.exe" or "lua") |
| 553 | cfg.project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir | 568 | cfg.project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir |
| 554 | 569 | ||
| 555 | do | 570 | do |
| 556 | local lua_bindir = detected.lua_bindir or hardcoded.LUA_BINDIR or (arg and arg[-1] and arg[-1]:gsub("[\\/][^\\/]+$", "")) | 571 | local lua_bindir = detected.lua_bindir or hardcoded.LUA_BINDIR or (first_arg and first_arg:gsub("[\\/][^\\/]+$", "")) |
| 557 | local lua_dir = detected.lua_dir or hardcoded.LUA_DIR or (lua_bindir and lua_bindir:gsub("[\\/]bin$", "")) | 572 | local lua_dir = detected.lua_dir or hardcoded.LUA_DIR or (lua_bindir and lua_bindir:gsub("[\\/]bin$", "")) |
| 558 | cfg.variables = { | 573 | cfg.variables = { |
| 559 | LUA_DIR = lua_dir, | 574 | LUA_DIR = lua_dir, |
