aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2019-03-14 21:59:18 -0300
committerHisham Muhammad <hisham@gobolinux.org>2019-03-14 23:19:39 -0300
commit83dceb3606505c226789e58ec7eb467da28ee204 (patch)
tree64d747f3bc33cb82efd25fa83aaeda5f6bca8afc /src
parent26b22259dd5e9380a38e06577345918885eb5707 (diff)
downloadluarocks-83dceb3606505c226789e58ec7eb467da28ee204.tar.gz
luarocks-83dceb3606505c226789e58ec7eb467da28ee204.tar.bz2
luarocks-83dceb3606505c226789e58ec7eb467da28ee204.zip
util: when bootstrapped, return self path as wrapper
Avoid reporting itself via the true path of the script; use the wrapper instead. That is, instead of ``` Error: Argument missing. See '$HOME/.luarocks/lib/luarocks/rocks-5.3/luarocks/dev-1/bin/luarocks help install'. ``` report ``` Error: Argument missing. See '$HOME/.luarocks/bin/luarocks help install'. ``` See https://github.com/luarocks/luarocks/issues/952#issuecomment-449966779
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/util.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 7f7ad80f..2d44c189 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -352,7 +352,16 @@ function util.this_program(default)
352 cur = dbg.source 352 cur = dbg.source
353 i=i+1 353 i=i+1
354 end 354 end
355 return last:sub(1,1) == "@" and last:sub(2) or last 355 local prog = last:sub(1,1) == "@" and last:sub(2) or last
356
357 -- Check if we found the true path of a script that has a wrapper
358 local lrdir, binpath = prog:match("^(.*)/lib/luarocks/rocks%-[0-9.]*/[^/]+/[^/]+(/bin/[^/]+)$")
359 if lrdir then
360 -- Return the wrapper instead
361 return lrdir .. binpath
362 end
363
364 return prog
356end 365end
357 366
358function util.deps_mode_help(program) 367function util.deps_mode_help(program)