1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-12 11:10:29 +00:00

Better shell.programs() fix

Prevents duplicate entries
This commit is contained in:
Daniel Ratcliffe 2017-05-16 23:34:53 +01:00
parent fb00698557
commit 19c8613dea

View File

@ -171,6 +171,9 @@ function shell.programs( _bIncludeHidden )
local sFile = tList[n]
if not fs.isDir( fs.combine( sPath, sFile ) ) and
(_bIncludeHidden or string.sub( sFile, 1, 1 ) ~= ".") then
if #sFile > 4 and sFile:sub(-4) == ".lua" then
sFile = sFile:sub(1,-5)
end
tItems[ sFile ] = true
end
end
@ -180,11 +183,7 @@ function shell.programs( _bIncludeHidden )
-- Sort and return
local tItemList = {}
for sItem, b in pairs( tItems ) do
if sItem:sub(-4) == ".lua" then
table.insert( tItemList, sItem:sub(1,-5) )
else
table.insert( tItemList, sItem )
end
table.insert( tItemList, sItem )
end
table.sort( tItemList )
return tItemList