mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-21 06:26:55 +00:00
Add Check to delete.lua (#236)
This commit is contained in:
parent
d8e1c73d26
commit
00c395f689
@ -9,7 +9,10 @@ for i = 1, args.n do
|
||||
local files = fs.find(shell.resolve(args[i]))
|
||||
if #files > 0 then
|
||||
for n, file in ipairs(files) do
|
||||
fs.delete(file)
|
||||
local ok, err = pcall(fs.delete, file)
|
||||
if not ok then
|
||||
printError((err:gsub("^pcall: ", "")))
|
||||
end
|
||||
end
|
||||
else
|
||||
printError(args[i] .. ": No matching files")
|
||||
|
@ -39,6 +39,11 @@ describe("The rm program", function()
|
||||
expect(capture(stub, "rm"))
|
||||
:matches { ok = true, output = "Usage: rm <paths>\n", error = "" }
|
||||
end)
|
||||
|
||||
it("errors when trying to delete a read-only file", function()
|
||||
expect(capture(stub, "rm /rom/startup.lua"))
|
||||
:matches { ok = true, output = "", error = "/rom/startup.lua: Access denied\n" }
|
||||
end)
|
||||
|
||||
it("errors when a glob fails to match", function()
|
||||
expect(capture(stub, "rm", "never-existed"))
|
||||
|
Loading…
Reference in New Issue
Block a user