Il giorno sab 21 ago 2021 alle ore 23:33 Harald van Dijk <har...@gigawatt.nl> ha scritto:
> Hi again, > > Another bug: the exit status is not preserved. > > Consider > > busybox ash -c 'trap "echo ERR" ERR; false; echo $?' > > This prints ERR, and then 0, because the echo command completed > successfully. It is supposed to print ERR, and then 1, because like EXIT > actions, ERR actions are supposed to preserve the exit status of the > last command before the action was invoked. > Patch 11 and testsuite attached. In the test suite two cases are evaluated exit status =0 !0 I am also somewhat concerned that there may be cases where the global > variables "doingtrap" and "recursive" are set, but evalstring() exits > via raise_exception() and they are never cleared, preventing future ERR > handlers from running. I do not currently have a test case where it > matters, but am not convinced there are no test cases where it matters. > line 13.320 in evalstring exception_handler = savehandler; if (ex) longjmp(exception_handler->loc, ex); do you think that this might resolve the issue? exception_handler = savehandler; if (ex) { doingtrap = 0; recursive = 0; longjmp(exception_handler->loc, ex); } Obviously recursive should become a global variable. When an exception is raised, what is going to happen? Exit? In case of exit then it is not a problem, IMHO. Thank you, -R
--- src/shell/ash.c 2021-08-22 00:50:59.274681664 +0200 +++ src.5/shell/ash.c 2021-08-22 00:49:52.458681278 +0200 @@ -9288,12 +9288,14 @@ evaltree(union node *n, int flags) static bool recursive = 0; if(!recursive) { int savelineno = lineno; + savestatus = exitstatus; doingtrap = 1; recursive = 1; evalstring(trap[NSIG], 0); recursive = 0; doingtrap = 0; lineno = savelineno; + exitstatus = savestatus; if(eflag) exitshell(); }
testsuite.tgz
Description: application/gzip
_______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox