From 19c8613dea9b0e78aea24a0ef805341d5953d35b Mon Sep 17 00:00:00 2001 From: Daniel Ratcliffe Date: Tue, 16 May 2017 23:34:53 +0100 Subject: [PATCH] Better shell.programs() fix Prevents duplicate entries --- .../assets/computercraft/lua/rom/programs/shell | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/shell b/src/main/resources/assets/computercraft/lua/rom/programs/shell index de7dfc22d..7daffa9d4 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/shell +++ b/src/main/resources/assets/computercraft/lua/rom/programs/shell @@ -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