Add lua exit(code)

This commit is contained in:
Martin Lund 2024-04-13 16:44:07 +02:00
parent c5dac4fd33
commit e1e3e298bf
3 changed files with 16 additions and 0 deletions

View file

@ -315,6 +315,16 @@ error:
return 1;
}
// lua: exit(code)
static int exit_(lua_State *L)
{
long code = lua_tointeger(L, 1);
exit(code);
return 0;
}
static void script_buffer_run(lua_State *L, const char *script_buffer)
{
int error;
@ -341,6 +351,7 @@ static const struct luaL_Reg tio_lib[] =
{ "modem_send", modem_send},
{ "send", send},
{ "expect", expect},
{ "exit", exit_},
{NULL, NULL}
};