local args = {...}
local name = syscall.getTask(syscall.getpid()).name
local fs = require("sys.fs")

if not args[1] then
    while true do
        local content = syscall.read(0, 1024)
        if not content or content == "" then break end
        printInline(content)
    end
    print("")
    return
end

for _, arg in ipairs(args) do
    local filePath = arg
    if filePath:sub(1,1) ~= "/" then
        filePath = syscall.getcwd().."/"..filePath
    end

    if not fs.exists(filePath) then
        print(name..": Cannot access '"..arg.."': No such file.")
    else
        local fd = syscall.open(filePath, "r")
        while true do
            local content = syscall.read(fd, 1024)
            if not content or content == "" then break end
            printInline(content)
        end
        syscall.close(fd)
    end
end
print("")
