diff --git a/pycardium/main.c b/pycardium/main.c index 7aa126186b81699a1d714e44bf8716581c90dc71..f6c2933bc204ff4066e74a19c29bf33975adee03 100644 --- a/pycardium/main.c +++ b/pycardium/main.c @@ -64,10 +64,22 @@ int main(void) mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_apps)); if (cnt > 0) { - pyexec_file_if_exists(script_name); + int ret = pyexec_file_if_exists(script_name); + + 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(""); + } - /* Drop to REPL by reloading Pycardium */ - epic_exec(""); + /* The script ended execution normally; return to menu */ + epic_exit(0); } for (;;) {