jazzdotdev / jazz

The Scripting Engine that Combines Speed, Safety, and Simplicity
Apache License 2.0
146 stars 11 forks source link

lua arg inconsistency #190

Open Arnaz87 opened 5 years ago

Arnaz87 commented 5 years ago

When torchbear is run as torchbear lua_script some_arg (and also with a shebang), the lua global arg is set to {"lua_script", "some_arg"} but when it's just the command torchbear, arg is set to nil. It should be set to an empty table.

sineemore commented 5 years ago

Example illustrating the issue:

init.lua

print("arg:", arg)
print("arg length:", #arg)

Executing torchbear

$ torchbear
arg:    nil
2019-01-26 20:58:44 ERROR:      init.lua:2: attempt to get length of a nil value (global 'arg')
stack traceback:
        init.lua:2: in local 'init_f'
        [string "?"]:15: in function <[string "?"]:11>
        [C]: in function 'xpcall'
        [string "?"]:11: in main chunk

Executing torchbear init.lua (interpreter mode)

$ torchbear init.lua
arg:    table: 0x5641b9f72b30
arg length:     1