diff options
Diffstat (limited to 'src/luarocks/cfg.lua')
-rw-r--r-- | src/luarocks/cfg.lua | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 2904146b..87777b86 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -35,6 +35,21 @@ major_version = program_version:match("([^.]%.[^.])") | |||
35 | 35 | ||
36 | local persist = require("luarocks.persist") | 36 | local persist = require("luarocks.persist") |
37 | 37 | ||
38 | _M.errorcodes = setmetatable({ | ||
39 | OK = 0, | ||
40 | UNSPECIFIED = 1, | ||
41 | PERMISSIONDENIED = 2, | ||
42 | },{ | ||
43 | __index = function(t, key) | ||
44 | local val = rawget(t, key) | ||
45 | if not val then | ||
46 | error("'"..tostring(key).."' is not a valid errorcode", 2) | ||
47 | end | ||
48 | return val | ||
49 | end | ||
50 | }) | ||
51 | |||
52 | |||
38 | local popen_ok, popen_result = pcall(io.popen, "") | 53 | local popen_ok, popen_result = pcall(io.popen, "") |
39 | if popen_ok then | 54 | if popen_ok then |
40 | if popen_result then | 55 | if popen_result then |
@@ -43,7 +58,7 @@ if popen_ok then | |||
43 | else | 58 | else |
44 | io.stderr:write("Your version of Lua does not support io.popen,\n") | 59 | io.stderr:write("Your version of Lua does not support io.popen,\n") |
45 | io.stderr:write("which is required by LuaRocks. Please check your Lua installation.\n") | 60 | io.stderr:write("which is required by LuaRocks. Please check your Lua installation.\n") |
46 | os.exit(1) | 61 | os.exit(_M.errorcodes.UNSPECIFIED) |
47 | end | 62 | end |
48 | 63 | ||
49 | -- System detection: | 64 | -- System detection: |