small fixes

This commit is contained in:
TopchetoEU 2025-02-06 17:46:02 +02:00
parent 5ed6f192b1
commit a8f5717b56
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
4 changed files with 22 additions and 19 deletions

View File

@ -3,7 +3,6 @@
-- Written by Cosmin Apreutesei. Public Domain.
-- Reworked from the (in)famous coro lib
---@diagnostic disable: duplicate-set-field
local old_create = coroutine.create;
local old_close = coroutine.close;

View File

@ -50,21 +50,21 @@ return function (glob)
--- @param self string
function glob.string:quotesh()
return "'" .. self
:gsub("*", "\\*")
:gsub("?", "\\?")
:gsub("~", "\\~")
:gsub("$", "\\$")
:gsub("&", "\\&")
:gsub("|", "\\|")
:gsub(";", "\\;")
:gsub("<", "\\<")
:gsub(">", "\\>")
:gsub("(", "\\)")
:gsub("[", "\\]")
:gsub("{", "\\}")
:gsub("%\\", "\\\\")
:gsub("\'", "\\\'")
:gsub("\"", "\\\"")
:gsub("`", "\\`") .. "'";
:gsub("%*", "\\*")
:gsub("%?", "\\?")
:gsub("%~", "\\~")
:gsub("%$", "\\$")
:gsub("%&", "\\&")
:gsub("%|", "\\|")
:gsub("%;", "\\;")
:gsub("%<", "\\<")
:gsub("%>", "\\>")
:gsub("%(", "\\)")
:gsub("%[", "\\]")
:gsub("%{", "\\}")
:gsub("%%\\", "\\\\")
:gsub("%\'", "\\\'")
:gsub("%\"", "\\\"")
:gsub("%`", "\\`") .. "'";
end
end

View File

@ -16,8 +16,12 @@ function exports.pwd()
return os.getenv "PWD" or "./";
end
--- @param path string
function exports.ls(path)
return os.execute("ls ")
local f = assert(io.popen("ls " .. path:quotesh()));
local res = f:read "*a";
f:close();
return res;
end
return exports;

View File

@ -213,7 +213,7 @@ function exports.main(...)
elseif mod and type(mod.main) == "function" then
return mod.main(...);
end
end, ...);
end, unpack(args));
else
return exports.repl();
end