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

@ -237,6 +237,9 @@ In addition to the Lua API tio makes the following functions available:
Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM. Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM.
exit(code)
Exit with code.
high(line) high(line)
Set tty line high. Set tty line high.

View file

@ -389,6 +389,8 @@ Send string.
Send file using x/y-modem protocol. Send file using x/y-modem protocol.
Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM. Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM.
.IP "\fBexit(code)"
Exit with exit code.
.IP "\fBhigh(line)" .IP "\fBhigh(line)"
Set tty line high. Set tty line high.
.IP "\fBlow(line)" .IP "\fBlow(line)"

View file

@ -315,6 +315,16 @@ error:
return 1; 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) static void script_buffer_run(lua_State *L, const char *script_buffer)
{ {
int error; int error;
@ -341,6 +351,7 @@ static const struct luaL_Reg tio_lib[] =
{ "modem_send", modem_send}, { "modem_send", modem_send},
{ "send", send}, { "send", send},
{ "expect", expect}, { "expect", expect},
{ "exit", exit_},
{NULL, NULL} {NULL, NULL}
}; };