Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/main/resources/assets/computercraft/lua/rom/programs/shell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ function shell.resolveProgram( _sCommand )
end

-- If the path is a global path, use it directly
local sStartChar = string.sub( _sCommand, 1, 1 )
if sStartChar == "/" or sStartChar == "\\" then
local sPath = fs.combine( "", _sCommand )
if _sCommand:find("/") or _sCommand:find("\\") then
local sPath = shell.resolve( _sCommand )
if fs.exists( sPath ) and not fs.isDir( sPath ) then
return sPath
else
Expand Down Expand Up @@ -299,9 +298,9 @@ function shell.programs( _bIncludeHidden )
end

local function completeProgram( sLine )
if #sLine > 0 and string.sub( sLine, 1, 1 ) == "/" then
if #sLine > 0 and (sLine:find("/") or sLine:find("\\")) then
-- Add programs from the root
return fs.complete( sLine, "", true, false )
return fs.complete( sLine, sDir, true, false )

else
local tResults = {}
Expand All @@ -318,6 +317,16 @@ local function completeProgram( sLine )
end
end

-- Add all subdirectories. We don't include files as they will be added in the block below
local tDirs = fs.complete( sLine, sDir, false, false )
for i = 1, #tDirs do
local sResult = tDirs[i]
if not tSeen[ sResult ] then
table.insert (tResults, sResult )
tSeen [ sResult ] = true
end
end

-- Add programs from the path
local tPrograms = shell.programs()
for n=1,#tPrograms do
Expand Down