1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-31 05:33:00 +00:00

Add shell.execute

This functions the same as shell.run, but does not tokenise the
arguments. This allows us to pass command line arguments through to
another program without having to re-quote them.

Closes #417
This commit is contained in:
SquidDev
2020-05-02 11:05:09 +01:00
parent e1663f3df0
commit fb64b6017b
4 changed files with 39 additions and 14 deletions

View File

@@ -6,19 +6,25 @@ describe("The shell", function()
end)
end)
describe("shell.run", function()
it("sets the arguments", function()
local handle = fs.open("test-files/out.txt", "w")
handle.writeLine("_G.__arg = arg")
handle.close()
shell.run("/test-files/out.txt", "arg1", "arg2")
fs.delete("test-files/out.txt")
describe("shell.execute", function()
it("parses in arguments verbatim", function()
shell.execute("/test-rom/data/dump-args", "arg1", "arg 2")
local args = _G.__arg
_G.__arg = nil
expect(args):same { [0] = "/test-files/out.txt", "arg1", "arg2" }
expect(args):same { [0] = "/test-rom/data/dump-args", "arg1", "arg 2" }
end)
end)
describe("shell.run", function()
it("tokenises the arguments", function()
shell.run("/test-rom/data/dump-args", "arg1", "arg 2")
local args = _G.__arg
_G.__arg = nil
expect(args):same { [0] = "/test-rom/data/dump-args", "arg1", "arg", "2" }
end)
end)