From 7555a9598d947abd28bb3271dcbc72faa6a8f021 Mon Sep 17 00:00:00 2001 From: payonel Date: Fri, 5 Feb 2016 20:36:24 -0800 Subject: [PATCH] fix cp one file system option and fix no args to time command --- .../assets/opencomputers/loot/OpenOS/bin/cp.lua | 17 ++++------------- .../opencomputers/loot/OpenOS/bin/time.lua | 7 +++++-- 2 files changed, 9 insertions(+), 15 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 77f009b46..ebca97702 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua @@ -59,16 +59,7 @@ local function areEqual(path1, path2) return result end -local function isMount(path) - path = fs.canonical(path) - for _, mountPath in fs.mounts() do - if path == fs.canonical(mountPath) then - return true - end - end -end - -local function recurse(fromPath, toPath) +local function recurse(fromPath, toPath, origin) status(fromPath, toPath) if fs.isDirectory(fromPath) then if not options.r then @@ -82,12 +73,12 @@ local function recurse(fromPath, toPath) -- 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 isMount(fromPath) then + fs.makeDirectory(toPath) + if options.x and origin and fs.get(fromPath) ~= origin then return true end - fs.makeDirectory(toPath) for file in fs.list(fromPath) do - local result, reason = recurse(fs.concat(fromPath, file), fs.concat(toPath, file)) + local result, reason = recurse(fs.concat(fromPath, file), fs.concat(toPath, file), origin or fs.get(fromPath)) if not result then return nil, reason end diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/time.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/time.lua index 8edd9436c..62bc90e71 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/time.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/time.lua @@ -1,8 +1,11 @@ local sh = require('sh') local clock_before = os.clock() -sh.execute(nil, ...) -local cmd_result = sh.getLastExitCode() +local cmd_result = 0 +if ... then + sh.execute(nil, ...) + cmd_result = sh.getLastExitCode() +end local clock_after = os.clock() local clock_diff = clock_after - clock_before