1
0
mirror of https://github.com/skywind3000/z.lua synced 2026-03-14 11:49:48 +00:00

fixed: os.interpreter()

This commit is contained in:
skywind3000
2018-11-21 16:45:38 +08:00
parent dac25a7197
commit 7c37f442ca

24
z.lua
View File

@@ -379,6 +379,22 @@ function os.path.subdir(basename, subname)
end
-----------------------------------------------------------------------
-- check single name element
-----------------------------------------------------------------------
function os.path.single(path)
if string.match(path, '/') then
return false
end
if windows then
if string.match(path, '\\') then
return false
end
end
return true
end
-----------------------------------------------------------------------
-- expand user home
-----------------------------------------------------------------------
@@ -415,8 +431,12 @@ function os.interpreter()
return nil
end
local lua = arg[-1]
if lua == 'lua' then
return os.path.which('lua')
if os.path.single(lua) then
local path = os.path.which(lua)
if not os.path.isabs(path) then
return os.path.abspath(path)
end
return path
end
return os.path.abspath(lua)
end