add path join

pull/43/head
Ahmed Zamouche 2023-12-05 13:52:18 +01:00
parent 31944b41ea
commit c0a4f96d56
2 changed files with 14 additions and 2 deletions

View File

@ -54,7 +54,7 @@ end
local function get_ssh_hosts(path)
local hosts = {}
path = path or utils.os.home() .. "/.ssh/config"
path = path or utils.os.path.join({ utils.os.home(), ".ssh", "config" })
if type(path) ~= "string" then
print("expected arg path of type 'string' actual '" .. type(path))

View File

@ -66,7 +66,7 @@ M.os = {}
function M.os.name()
-- Unix, Linux variants
local fh, err = assert(io.popen("uname -o 2>/dev/null", "r"))
if fh then
if err ~= nil and fh then
return fh:read()
end
return "Windows"
@ -82,4 +82,16 @@ function M.os.home()
end
end
M.os.path = {}
function M.os.path.join(t)
local sep = nil
if M.os.name() == "Windows" then
sep = "\\"
else
sep = "/"
end
return table.concat(t, sep)
end
return M