This commit is contained in:
kepler155c@gmail.com 2020-06-13 20:26:17 -06:00
parent 9bf91a8762
commit 7df4a47ba0
1 changed files with 19 additions and 15 deletions

View File

@ -149,26 +149,30 @@ function shell.resolveProgram(_sCommand)
_sCommand = tAliases[_sCommand] _sCommand = tAliases[_sCommand]
end end
local path = shell.resolve(_sCommand) local function check(f)
if fs.exists(path) and not fs.isDir(path) then return fs.exists(f) and not fs.isDir(f) and f
return path
end
if fs.exists(path .. '.lua') then
return path .. '.lua'
end end
-- Otherwise, look on the path variable local function inPath()
if not _sCommand:find('/') then -- Otherwise, look on the path variable
for sPath in string.gmatch(PATH or '', "[^:]+") do if not _sCommand:find('/') then
sPath = fs.combine(sPath, _sCommand ) for sPath in string.gmatch(PATH or '', "[^:]+") do
if fs.exists(sPath) and not fs.isDir(sPath) then sPath = fs.combine(sPath, _sCommand )
return sPath if fs.exists(sPath) and not fs.isDir(sPath) then
end return sPath
if fs.exists(sPath .. '.lua') then end
return sPath .. '.lua' if fs.exists(sPath .. '.lua') then
return sPath .. '.lua'
end
end end
end end
end end
return check(_sCommand)
or check(_sCommand .. '.lua')
or check(shell.resolve(_sCommand))
or check(shell.resolve(_sCommand) .. '.lua')
or inPath()
end end
function shell.programs(_bIncludeHidden) function shell.programs(_bIncludeHidden)