From 83dceb3606505c226789e58ec7eb467da28ee204 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 14 Mar 2019 21:59:18 -0300 Subject: 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 --- src/luarocks/util.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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) cur = dbg.source i=i+1 end - return last:sub(1,1) == "@" and last:sub(2) or last + local prog = last:sub(1,1) == "@" and last:sub(2) or last + + -- Check if we found the true path of a script that has a wrapper + local lrdir, binpath = prog:match("^(.*)/lib/luarocks/rocks%-[0-9.]*/[^/]+/[^/]+(/bin/[^/]+)$") + if lrdir then + -- Return the wrapper instead + return lrdir .. binpath + end + + return prog end function util.deps_mode_help(program) -- cgit v1.2.3-55-g6feb