From d9bd0096beccf78f85409a889e1b2fbf47102905 Mon Sep 17 00:00:00 2001 From: payonel Date: Thu, 11 Feb 2016 23:03:44 -0800 Subject: [PATCH] fixing cp -x --- .../resources/assets/opencomputers/loot/OpenOS/bin/cp.lua | 7 ++++++- .../assets/opencomputers/loot/OpenOS/bin/install.lua | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua index 1ae53daaa..bbeed1f81 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua @@ -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 diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua index 95ae88c66..940eddbd3 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua @@ -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