mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 03:00:30 +00:00
Set the arg table within shell.run
This makes us a little more compatible with Lua
This commit is contained in:
parent
68bf3a71dc
commit
d661cfa88b
@ -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
|
||||
|
17
src/test/resources/test-rom/spec/programs/shell_spec.lua
Normal file
17
src/test/resources/test-rom/spec/programs/shell_spec.lua
Normal 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)
|
Loading…
Reference in New Issue
Block a user