fixing cp -x

This commit is contained in:
payonel 2016-02-11 23:03:44 -08:00
parent 54de3fe89d
commit d9bd0096be
2 changed files with 7 additions and 2 deletions

View File

@ -59,6 +59,11 @@ local function areEqual(path1, path2)
return result
end
local mounts = {}
for dev,path in fs.mounts() do
mounts[fs.canonical(path)] = dev
end
local function recurse(fromPath, toPath, origin)
status(fromPath, toPath)
if fs.isDirectory(fromPath) then
@ -70,7 +75,7 @@ local function recurse(fromPath, toPath, origin)
-- my real cp always does this, even with -f, -n or -i.
return nil, "cannot overwrite non-directory `" .. toPath .. "' with directory `" .. fromPath .. "'"
end
if options.x and origin and fs.get(fromPath) ~= origin then
if options.x and origin and mounts[fs.canonical(fromPath)] then
return true
end
if fs.get(fromPath) == fs.get(toPath) and fs.canonical(fs.path(toPath)):find(fs.canonical(fromPath),1,true) then

View File

@ -60,7 +60,7 @@ io.write("Installing " .. name .." to device " .. (choice.getLabel() or choice.a
os.sleep(0.25)
local cpPath = filesystem.concat(findMount(filesystem.get(os.getenv("_")).address), "bin/cp")
local cpOptions = "-vrx" .. (options.u and "ui " or "")
local cpSource = filesystem.concat(findMount(fromAddress), options.fromDir or "/", "*")
local cpSource = filesystem.concat(findMount(fromAddress), options.fromDir or "/")
local cpDest = findMount(choice.address) .. "/"
local result, reason = os.execute(cpPath .. " " .. cpOptions .. " " .. cpSource .. " " .. cpDest)
if not result then