Set the arg table within shell.run

This makes us a little more compatible with Lua
This commit is contained in:
SquidDev 2019-05-24 18:42:19 +01:00
parent 68bf3a71dc
commit d661cfa88b
2 changed files with 22 additions and 1 deletions

View File

@ -130,8 +130,12 @@ local function run( _sCommand, ... )
end
multishell.setTitle( multishell.getCurrent(), sTitle )
end
local sDir = fs.getDir( sPath )
local result = os.run( createShellEnv( sDir ), sPath, ... )
local env = createShellEnv( sDir )
env[ "arg" ] = { [0] = _sCommand, ... }
local result = os.run( env, sPath, ... )
tProgramStack[#tProgramStack] = nil
if multishell then
if #tProgramStack > 0 then

View File

@ -0,0 +1,17 @@
describe("The shell", function()
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")
local args = _G.__arg
_G.__arg = nil
expect(args):same { [0] = "/test-files/out.txt", "arg1", "arg2" }
end)
end)
end)