Update shell to work with new term.lua

This commit is contained in:
Łukasz Magiera 2014-08-07 17:16:03 +02:00
parent c791bcc00c
commit 9c6bbbef75

View File

@ -207,12 +207,13 @@ local function hintHandler(line)
if lastSearch == line then return matches end if lastSearch == line then return matches end
else else
local matches = getMatchingFiles(after) local matches = getMatchingFiles(after)
if #matches == 1 then
lastSearch = "" for k in ipairs(matches)do
local ret = base .. space .. after .. matches[1]:gsub(after:match("[/]*(%w+)$"),"",1) local ret = base .. space .. after .. (matches[k]):gsub(after:match("[/]*(%w+)$") or "","",1)
return ret:gsub("[^/]$","%1 ") matches[k] = ret:gsub("[^/]$","%1 "):gsub("/$","")
end end
if lastSearch == line then return matches end
return matches
end end
lastSearch = line lastSearch = line
end end
@ -227,7 +228,8 @@ if #args == 0 and (io.input() == io.stdin or options.i) and not options.c then
term.clear() term.clear()
end end
while term.isAvailable() do while term.isAvailable() do
local command = term.read(history, nil, hintHandler, drawPrompt) drawPrompt()
local command = term.read(history, nil, hintHandler)
if not command then if not command then
term.write("exit\n") term.write("exit\n")
return -- eof return -- eof