diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-03-14 21:59:18 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-03-14 23:19:39 -0300 |
commit | 83dceb3606505c226789e58ec7eb467da28ee204 (patch) | |
tree | 64d747f3bc33cb82efd25fa83aaeda5f6bca8afc | |
parent | 26b22259dd5e9380a38e06577345918885eb5707 (diff) | |
download | luarocks-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
-rw-r--r-- | src/luarocks/util.lua | 11 |
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 | ||
356 | end | 365 | end |
357 | 366 | ||
358 | function util.deps_mode_help(program) | 367 | function util.deps_mode_help(program) |