Skip to content
Snippets Groups Projects
Commit ee24d515 authored by rahix's avatar rahix
Browse files

feat(pycardium): Return to menu when a script ends cleanly


Instead of dropping to REPL and silently requiring the user to return to
menu via button-press, directly call epic_exit(0) when a script
terminates execution normally (i.e. not via exception).

Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 79cee7a9
No related branches found
No related tags found
No related merge requests found
...@@ -64,12 +64,24 @@ int main(void) ...@@ -64,12 +64,24 @@ int main(void)
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_apps)); mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_apps));
if (cnt > 0) { if (cnt > 0) {
pyexec_file_if_exists(script_name); int ret = pyexec_file_if_exists(script_name);
/* Drop to REPL by reloading Pycardium */ if (ret == 0) {
/*
* The script was aborted via uncaught exception; Sadly
* we can't find out what happened so let's hope it was
* a KeyboardInterrupt and drop to REPL.
*
* In the future it might be interesting to rework this
* so any other exception will lead to epic_exit(1).
*/
epic_exec(""); epic_exec("");
} }
/* The script ended execution normally; return to menu */
epic_exit(0);
}
for (;;) { for (;;) {
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
if (pyexec_raw_repl() != 0) { if (pyexec_raw_repl() != 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment