mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8.9
This commit is contained in:
commit
67d595196c
@ -93,7 +93,7 @@ local function recurse(fromPath, toPath, origin)
|
|||||||
if options.x and origin and mounts[fs.canonical(fromPath)] then
|
if options.x and origin and mounts[fs.canonical(fromPath)] then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fs.get(fromPath) == fs.get(toPath) and fs.canonical(toPath):find(fs.canonical(fromPath),1,true) then
|
if fs.get(fromPath) == fs.get(toPath) and (fs.canonical(toPath).."/"):find(fs.canonical(fromPath).."/",1,true) then
|
||||||
return nil, "cannot copy a directory, `" .. fromPath .. "', into itself, `" .. toPath .. "'"
|
return nil, "cannot copy a directory, `" .. fromPath .. "', into itself, `" .. toPath .. "'"
|
||||||
end
|
end
|
||||||
if not fs.exists(toPath) then
|
if not fs.exists(toPath) then
|
||||||
|
@ -67,7 +67,8 @@ end
|
|||||||
|
|
||||||
for _, row in ipairs(result) do
|
for _, row in ipairs(result) do
|
||||||
for col, value in ipairs(row) do
|
for col, value in ipairs(row) do
|
||||||
io.write(text.padRight(value, m[col] + 2))
|
local padding = col == #row and 0 or 2
|
||||||
|
io.write(text.padRight(value, m[col] + padding))
|
||||||
end
|
end
|
||||||
print()
|
print()
|
||||||
end
|
end
|
||||||
|
@ -133,7 +133,7 @@ if #args == 0 or options.i then
|
|||||||
term.write(tostring(env._PROMPT or "lua> "))
|
term.write(tostring(env._PROMPT or "lua> "))
|
||||||
gpu.setForeground(foreground)
|
gpu.setForeground(foreground)
|
||||||
local command = term.read(history, nil, hint)
|
local command = term.read(history, nil, hint)
|
||||||
if command == nil or command == "" then -- eof
|
if not command then -- eof
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local code, reason
|
local code, reason
|
||||||
|
@ -10,32 +10,33 @@ if #args < 2 then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function is_mount(path)
|
local function is_mount(path)
|
||||||
if not fs.isDirectory(path) then return false end
|
end
|
||||||
path = fs.canonical(path) .. '/'
|
|
||||||
|
local from = args[1] ~= "" and shell.resolve(args[1])
|
||||||
|
local to = args[2] ~= "" and shell.resolve(args[2])
|
||||||
|
|
||||||
|
if not from or not fs.exists(from) then
|
||||||
|
io.stderr:write(string.format("No such file or directory: '%s'\n", args[1]))
|
||||||
|
return 1
|
||||||
|
elseif not to then
|
||||||
|
io.stderr:write(string.format("Cannot move '%s' to '%s' No such file or directory\n", args[1], args[2]))
|
||||||
|
return 1
|
||||||
|
elseif fs.get(from).isReadOnly() then
|
||||||
|
io.stderr:write("cannot remove " .. args[1] .. ", filesystem is readonly\n");
|
||||||
|
return 1
|
||||||
|
elseif fs.get(to).isReadOnly() then
|
||||||
|
io.stderr:write("cannot write to " .. args[2] .. ", filesystem is readonly\n");
|
||||||
|
return 1
|
||||||
|
elseif fs.isDirectory(from) then
|
||||||
|
local path = fs.canonical(from) .. '/'
|
||||||
for driver, mount_point in fs.mounts() do
|
for driver, mount_point in fs.mounts() do
|
||||||
if path == mount_point then
|
if path == mount_point then
|
||||||
return true
|
io.stderr:write("cannot move " .. args[1] .. ", it is a mount point\n");
|
||||||
|
return 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_readonly(path)
|
|
||||||
return fs.get(path).isReadOnly()
|
|
||||||
end
|
|
||||||
|
|
||||||
local from = shell.resolve(args[1])
|
|
||||||
local to = shell.resolve(args[2])
|
|
||||||
|
|
||||||
if is_readonly(to) then
|
|
||||||
io.stderr:write("cannot write to " .. to .. ", filesystem is readonly\n");
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if is_mount(from) then
|
|
||||||
io.stderr:write("cannot move " .. from .. ", it is a mount point\n");
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if fs.isDirectory(to) then
|
if fs.isDirectory(to) then
|
||||||
to = to .. "/" .. fs.name(from)
|
to = to .. "/" .. fs.name(from)
|
||||||
end
|
end
|
||||||
@ -44,16 +45,15 @@ if fs.exists(to) then
|
|||||||
io.stderr:write("target file exists\n")
|
io.stderr:write("target file exists\n")
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
fs.remove(to)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local result, reason
|
local result, reason
|
||||||
if fs.get(from) == fs.get(to) then -- same filesystem
|
if fs.get(from) == fs.get(to) then -- same filesystem
|
||||||
result, reason = os.rename(from, to)
|
result, reason = os.rename(from, to)
|
||||||
else
|
else
|
||||||
result, reason = sh.execute(nil, shell.resolve("cp","lua"), "-r", from, to)
|
result, reason = sh.execute(nil, shell.resolve("cp","lua"), "-rf", from, to)
|
||||||
if result then
|
if result then
|
||||||
result, reason = sh.execute(nil, shell.resolve("rm","lua"), "-r", from)
|
result, reason = sh.execute(nil, shell.resolve("rm","lua"), "-rf", from)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,6 +24,21 @@ local bVerbose = options.v or options.verbose
|
|||||||
local bEmptyDirs = options.d or options.dir
|
local bEmptyDirs = options.d or options.dir
|
||||||
local promptLevel = (options.I and 3) or (options.i and 1) or 0
|
local promptLevel = (options.I and 3) or (options.i and 1) or 0
|
||||||
|
|
||||||
|
bVerbose = bVerbose and not bForce
|
||||||
|
promptLevel = bForce and 0 or promptLevel
|
||||||
|
|
||||||
|
local function perr(...)
|
||||||
|
if not bForce then
|
||||||
|
io.stderr:write(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function pout(...)
|
||||||
|
if not bForce then
|
||||||
|
io.stdout:write(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local metas = {}
|
local metas = {}
|
||||||
|
|
||||||
-- promptLevel 3 done before fs.exists
|
-- promptLevel 3 done before fs.exists
|
||||||
@ -50,6 +65,9 @@ local function unlink(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function confirm()
|
local function confirm()
|
||||||
|
if bForce then
|
||||||
|
return true
|
||||||
|
end
|
||||||
local r = io.read("*l")
|
local r = io.read("*l")
|
||||||
return r == 'y' or r == 'yes'
|
return r == 'y' or r == 'yes'
|
||||||
end
|
end
|
||||||
@ -61,7 +79,7 @@ local function remove_all(parent)
|
|||||||
|
|
||||||
local all_ok = true
|
local all_ok = true
|
||||||
if bRec and promptLevel == 1 then
|
if bRec and promptLevel == 1 then
|
||||||
io.stdout:write(string.format("rm: descend into directory `%s'? ", parent.rel))
|
pout(string.format("rm: descend into directory `%s'? ", parent.rel))
|
||||||
if not confirm() then
|
if not confirm() then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -81,16 +99,13 @@ local function remove(meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not _exists(meta) then
|
if not _exists(meta) then
|
||||||
io.stderr:write(
|
perr(string.format("rm: cannot remove `%s': No such file or directory\n", meta.rel))
|
||||||
string.format("rm: cannot remove `%s': No such file or directory\n", meta.rel))
|
|
||||||
return false
|
return false
|
||||||
elseif _dir(meta) and not bRec and not (_empty(meta) and bEmptyDirs) then
|
elseif _dir(meta) and not bRec and not (_empty(meta) and bEmptyDirs) then
|
||||||
if not bEmptyDirs then
|
if not bEmptyDirs then
|
||||||
io.stderr:write(
|
perr(string.format("rm: cannot remove `%s': Is a directory\n", meta.rel))
|
||||||
string.format("rm: cannot remove `%s': Is a directory\n", meta.rel))
|
|
||||||
else
|
else
|
||||||
io.stderr:write(
|
perr(string.format("rm: cannot remove `%s': Directory not empty\n", meta.rel))
|
||||||
string.format("rm: cannot remove `%s': Directory not empty\n", meta.rel))
|
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -98,11 +113,11 @@ local function remove(meta)
|
|||||||
local ok = true
|
local ok = true
|
||||||
if promptLevel == 1 then
|
if promptLevel == 1 then
|
||||||
if _dir(meta) then
|
if _dir(meta) then
|
||||||
io.stdout:write(string.format("rm: remove directory `%s'? ", meta.rel))
|
pout(string.format("rm: remove directory `%s'? ", meta.rel))
|
||||||
elseif meta.link then
|
elseif meta.link then
|
||||||
io.stdout:write(string.format("rm: remove symbolic link `%s'? ", meta.rel))
|
pout(string.format("rm: remove symbolic link `%s'? ", meta.rel))
|
||||||
else -- file
|
else -- file
|
||||||
io.stdout:write(string.format("rm: remove regular file `%s'? ", meta.rel))
|
pout(string.format("rm: remove regular file `%s'? ", meta.rel))
|
||||||
end
|
end
|
||||||
|
|
||||||
ok = confirm()
|
ok = confirm()
|
||||||
@ -110,14 +125,13 @@ local function remove(meta)
|
|||||||
|
|
||||||
if ok then
|
if ok then
|
||||||
if _readonly(meta) then
|
if _readonly(meta) then
|
||||||
io.stderr:write(
|
perr(string.format("rm: cannot remove `%s': Is read only\n", meta.rel))
|
||||||
string.format("rm: cannot remove `%s': Is read only\n", meta.rel))
|
|
||||||
return false
|
return false
|
||||||
elseif not unlink(_path(meta)) then
|
elseif not unlink(_path(meta)) then
|
||||||
io.stderr:write(meta.rel .. ": failed to be removed\n")
|
perr(meta.rel .. ": failed to be removed\n")
|
||||||
ok = false
|
ok = false
|
||||||
elseif bVerbose then
|
elseif bVerbose then
|
||||||
io.write("removed '" .. meta.rel .. "'\n");
|
pout("removed '" .. meta.rel .. "'\n");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -129,7 +143,7 @@ for _,arg in ipairs(args) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if promptLevel == 3 and #metas > 3 then
|
if promptLevel == 3 and #metas > 3 then
|
||||||
io.stdout:write(string.format("rm: remove %i arguments? ", #metas))
|
pout(string.format("rm: remove %i arguments? ", #metas))
|
||||||
if not confirm() then
|
if not confirm() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -140,3 +154,5 @@ for _,meta in ipairs(metas) do
|
|||||||
local result = remove(meta)
|
local result = remove(meta)
|
||||||
ok = ok and result
|
ok = ok and result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return bForce or ok
|
||||||
|
@ -57,9 +57,3 @@ event.listen("component_added", components_changed)
|
|||||||
event.listen("component_available", components_changed)
|
event.listen("component_available", components_changed)
|
||||||
event.listen("component_unavailable", components_changed)
|
event.listen("component_unavailable", components_changed)
|
||||||
|
|
||||||
event.listen("screen_resized", function(_,addr,w,h)
|
|
||||||
local window = term.internal.window()
|
|
||||||
if term.isAvailable(window) and term.screen(window) == addr and window.fullscreen then
|
|
||||||
window.w,window.h = w,h
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
@ -157,10 +157,10 @@ do
|
|||||||
computer.pushSignal("component_added", c, t)
|
computer.pushSignal("component_added", c, t)
|
||||||
end
|
end
|
||||||
os.sleep(0.5) -- Allow signal processing by libraries.
|
os.sleep(0.5) -- Allow signal processing by libraries.
|
||||||
computer.pushSignal("init") -- so libs know components are initialized.
|
|
||||||
|
|
||||||
status("Initializing system...")
|
status("Initializing system...")
|
||||||
os.sleep(0.1) -- Allow init processing.
|
|
||||||
|
computer.pushSignal("init") -- so libs know components are initialized.
|
||||||
|
require("event").pull(1, "init") -- Allow init processing.
|
||||||
runlevel = 1
|
runlevel = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -252,27 +252,32 @@ function sh.internal.createThreads(commands, eargs, env)
|
|||||||
|
|
||||||
threads[i] = thread
|
threads[i] = thread
|
||||||
|
|
||||||
if thread then
|
if not thread then
|
||||||
-- smart check if ios should be loaded
|
|
||||||
if tx.first(args, function(token) return token == "<" or token:find(">") end) then
|
|
||||||
args, reason = sh.internal.buildCommandRedirects(thread, args)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not args or not thread then
|
|
||||||
for i,t in ipairs(threads) do
|
for i,t in ipairs(threads) do
|
||||||
process.internal.close(t)
|
process.internal.close(t)
|
||||||
end
|
end
|
||||||
return nil, reason
|
return nil, reason
|
||||||
end
|
end
|
||||||
|
|
||||||
process.info(thread).data.args = tx.concat(args, eargs or {})
|
process.info(thread).data.args = args
|
||||||
end
|
end
|
||||||
|
|
||||||
if #threads > 1 then
|
if #threads > 1 then
|
||||||
sh.internal.buildPipeChain(threads)
|
sh.internal.buildPipeChain(threads)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i = 1, #threads do
|
||||||
|
local thread = threads[i]
|
||||||
|
local args = process.info(thread).data.args
|
||||||
|
|
||||||
|
-- smart check if ios should be loaded
|
||||||
|
if tx.first(args, function(token) return token == "<" or token:find(">") end) then
|
||||||
|
args, reason = sh.internal.buildCommandRedirects(thread, args)
|
||||||
|
end
|
||||||
|
|
||||||
|
process.info(thread).data.args = tx.concat(args, eargs or {})
|
||||||
|
end
|
||||||
|
|
||||||
return threads
|
return threads
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,6 +19,11 @@ local local_env = {unicode=unicode,event=event,process=process,W=W,kb=kb}
|
|||||||
function term.internal.open(...)
|
function term.internal.open(...)
|
||||||
local dx, dy, w, h = ...
|
local dx, dy, w, h = ...
|
||||||
local window = {x=1,y=1,fullscreen=select("#",...)==0,dx=dx or 0,dy=dy or 0,w=w,h=h,blink=true}
|
local window = {x=1,y=1,fullscreen=select("#",...)==0,dx=dx or 0,dy=dy or 0,w=w,h=h,blink=true}
|
||||||
|
event.listen("screen_resized", function(_,addr,w,h)
|
||||||
|
if term.isAvailable(window) and term.screen(window) == addr and window.fullscreen then
|
||||||
|
window.w,window.h = w,h
|
||||||
|
end
|
||||||
|
end)
|
||||||
return window
|
return window
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -239,7 +244,9 @@ function term.readKeyboard(ops)
|
|||||||
|
|
||||||
while true do
|
while true do
|
||||||
local name, address, char, code = term.internal.pull(input)
|
local name, address, char, code = term.internal.pull(input)
|
||||||
assert(term.isAvailable(), "term_unavailable")
|
if not term.isAvailable() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- we have to keep checking what kb is active in case it is switching during use
|
-- we have to keep checking what kb is active in case it is switching during use
|
||||||
-- we could have multiple screens, each with keyboards active
|
-- we could have multiple screens, each with keyboards active
|
||||||
|
@ -9,7 +9,7 @@ local local_env = {tx=tx,unicode=unicode}
|
|||||||
|
|
||||||
text.internal = {}
|
text.internal = {}
|
||||||
|
|
||||||
text.syntax = {"^%d*>>?&%d+$",";","&&","||?","^%d*>>?",">>?","<"}
|
text.syntax = {"^%d?>>?&%d+$",";","&&","||?","^%d?>>?",">>?","<"}
|
||||||
|
|
||||||
function --[[@delayloaded-start@]] text.detab(value, tabWidth)
|
function --[[@delayloaded-start@]] text.detab(value, tabWidth)
|
||||||
checkArg(1, value, "string")
|
checkArg(1, value, "string")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user