Фиксы ввода вывода и ls валидация параметров

This commit is contained in:
2026-06-14 02:35:17 +03:00
parent 5ef9eb1cb5
commit 14f47767b3
2 changed files with 17 additions and 3 deletions

View File

@@ -108,13 +108,22 @@ reg("ls", function(a)
local opts = {}
for i = 1, #a do
if a[i]:sub(1, 1) == "-" then
opts[a[i]] = true
local opt = a[i]
for j = 2, #opt do
local c = opt:sub(j, j)
if c ~= "a" and c ~= "l" then
error("ls: unknown option '" .. opt .. "'")
end
end
opts[opt] = true
else
path = resolvePath(a[i])
end
end
local cmdStr = "ls"
if #a > 0 then cmdStr = "ls " .. table.concat(a, " ") end
for i = 1, #a do
cmdStr = cmdStr .. " " .. tostring(a[i])
end
pendingCmd = { name = "ls", opts = opts, path = path,
prompt = curUser .. " " .. cwd .. "> " .. cmdStr }
state = ST_WAIT_FS
@@ -254,6 +263,7 @@ local function handleFSResponse(op, data)
end
queueLines(lines)
out[4] = ""
pendingCmd = nil
state = ST_IDLE
end

View File

@@ -267,11 +267,15 @@ function upd()
if inp[1] ~= nil then
local req = tostring(inp[1])
if #req > 0 and req ~= prevReq then
if #req == 0 then
prevReq = ""
elseif req ~= prevReq then
prevReq = req
local resp = processReq(req)
out[1] = resp
end
else
prevReq = ""
end
table.clear(inp)