|
Thanks V. As incomplete is checking for LUA_ERRSYNTAX I guess in Lua I can do similar thing by checking “near <eof>” error. So my shell looks like: LUA_PROMPT = "Lua> " LUA_PROMPT_MULTI = "Lua>> " function luashell( ctx ) print_sl ("Lua EOS Shell version 0.01\nCopyrights 2021 Varanda Labs\n\n" .. LUA_PROMPT) -- subscribe for events res,msg = eos.subscribe_event_by_name(ctx, "EV_SYS_TEXT_FROM_CONSOLE") if res == false then print(msg) end local f,msg, ok local err local chunk = "" local more = false while(1) do local ev, arg = eos.wait_event(ctx) if more == true then chunk = chunk .. arg f, msg = load(chunk) else f, msg = load(arg) end if f == nil then if string.find(msg, "<eof>") ~= nil then if more == false then -- if first time: chunk = chunk .. arg more = true end print_sl(LUA_PROMPT_MULTI) else print(“load error: " .. msg) chunk = "" more = false end else --local ok, e = xpcall( f, lua_error_handler ) local ok, msg = pcall(f) if ok == false then print(msg) end chunk = "" more = false print_sl(LUA_PROMPT) end end end
|