mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
fix cat when input is tty
This commit is contained in:
parent
9d544b3731
commit
0b767e6c7c
@ -7,8 +7,10 @@ if #args == 0 then
|
||||
args = {"-"}
|
||||
end
|
||||
|
||||
local input_method, input_param = "read", 2048
|
||||
|
||||
for i = 1, #args do
|
||||
local arg = args[i]
|
||||
local arg = shell.resolve(args[i])
|
||||
if fs.isDirectory(arg) then
|
||||
io.stderr:write(string.format('cat %s: Is a directory\n', arg))
|
||||
ec = 1
|
||||
@ -16,15 +18,16 @@ for i = 1, #args do
|
||||
local file, reason
|
||||
if args[i] == "-" then
|
||||
file, reason = io.stdin, "missing stdin"
|
||||
input_method, input_param = "readLine", false
|
||||
else
|
||||
file, reason = fs.open(shell.resolve(args[i]))
|
||||
file, reason = fs.open(arg)
|
||||
end
|
||||
if not file then
|
||||
io.stderr:write(string.format("cat: %s: %s\n", args[i], tostring(reason)))
|
||||
ec = 1
|
||||
else
|
||||
repeat
|
||||
local chunk = file:read(2048)
|
||||
local chunk = file[input_method](file, input_param)
|
||||
if chunk then
|
||||
io.write(chunk)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user