return function(argv, con) local runs = true local function parseArgs(ln) local iq, buf, args = false, '', {} local qt, esc = nil, false -- helper function local function psh() if #buf > 0 then table.insert(args, buf) end buf, qt = '', nil end for i = 1, #ln + 1 do local v = ln:sub(i, i) if ((v == ' ' or v == '\n' or v == '\t') and not iq) or v == '' then psh() elseif esc then esc, buf = false, buf.. v elseif v == '\\' then esc = true elseif (not qt or qt == v) and (v == '"' or v == "'") then psh() qt, iq = v, not iq else buf = buf.. v end end return args end local cd = 'A:' await(function() con.print(cd.. '>') con.down() local ln = con.getln() local argv = parseArgs(ln) if not argv[1] then -- nothing elseif argv[1]:lower() == 'dir' then local cp, f = 0, fsLs(cd) for _, v in pairs(f) do if cp + 14 + #cd >= con.w then con.print '\n'; cp = 0 end if cp == 0 then cp = #cd con.print(cd) else con.print ' : ' end local i = fsInfo(cd..v) local n, ext = v:match('(.+)%.(.+)$') n = n or v if #n > 8 then con.print(n:sub(1, 6) .. '~1') elseif #n < 8 then con.print(n ..(' '):rep(8 - #n)) end con.print ' ' if i.type == 'directory' then con.print '' elseif i.type == 'symlink' then con.print '' elseif i.type == 'other' then con.print '' elseif ext then con.print(ext:upper():sub(1, 3)) con.print((' '):rep(3 - #ext)) else con.print ' ' end cp = cp + 14 end con.print '\n' elseif argv[1]:match '%u:' then cd = argv[1] elseif argv[1]:lower() == 'type' then con.print(fsRead(argv[2])) con.print '\n' else con.println(argv[1].. ': command not found') end return not runs end) return sh end