aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/compat.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/compat.lua b/core/compat.lua
index 1bbf4a3b..953e06b4 100644
--- a/core/compat.lua
+++ b/core/compat.lua
@@ -17,3 +17,23 @@ function load(ld, source, mode, env)
if f and env then return setfenv(f, env) end
return f, err
end
+
+-- In Lua 5.1, `loadfile` did not take mode and environment parameters.
+local loadfile51 = loadfile
+function loadfile(filename, mode, env)
+ local f, err = loadfile51(filename)
+ if f and env then return setfenv(f, env) end
+ return f, err
+end
+
+-- TODO: string.rep
+-- In Lua 5.1, `string.rep` did not take separation string parameter.
+
+-- In Lua 5.1, `os.execute` returned an integer depending on shell availability.
+-- It also returned just a status code.
+local os_execute51 = os.execute
+function os.execute(command)
+ if not command then return os_execute51() ~= 0 end
+ local code = os_execute51(command)
+ return code == 0, 'exit', code
+end