Il giorno dom 5 set 2021 alle ore 21:40 Denys Vlasenko <[email protected]> ha scritto: > > > > @@ -9395,8 +9407,32 @@ evaltree(union node *n, int flags) > > > */ > > > dotrap(); > > > > > > - if (checkexit & status) > > > - raise_exception(EXEND); > > > + if (checkexit & status) { > > > + if (trap[NTRAP_ERR] && !in_trap_ERR) { > > > + int err; > > > + struct jmploc *volatile savehandler = > > > exception_handler; > > > + struct jmploc jmploc; > > > + > > > + in_trap_ERR = 1; > > > + trap_depth++; > > > + err = setjmp(jmploc.loc); > > > + if (!err) { > > > + exception_handler = &jmploc; > > > + savestatus = exitstatus; > > > + evalstring(trap[NTRAP_ERR], 0); > > > + } > > > + trap_depth--; > > > + in_trap_ERR = 0; > > > + > > > + exception_handler = savehandler; > > > + if (err && exception_type != EXERROR) > > > + longjmp(exception_handler->loc, 1); > > > + > > > + exitstatus = savestatus; > > > + } > > > + if (eflag) > > > + raise_exception(EXEND); > > > + } > > > if (flags & EV_EXIT) > > > raise_exception(EXEND); > > > > if (eflag) > > exitshell(); > > } > > if (flags & EV_EXIT) > > exitshell(); > > > > Otherwise LINENO is not reported correctly when these exceptions are raised. > > Walk me through the mechanism of this failure. You mean that LINENO > in EXIT trap will be counting incorrectly?
I took my v021 patch and replaced that two exitshell() with raise_exception() I ran the test suite and it happens that the exit in function returns the right line number with exitshell() but not with raise_exception(). The right line number should be within the function with FUNCNAME set, instead I read the right FUNCNAME but the LINENO of the script in which the function is called. In attachment the diff file: failures in test 4, 7, A and C. > > For sure the first one is needed to have exitshell(). > > All LINENO problems are to be fixed in a separate patch - ok > IIRC you want to fix other LINENO problems anyway, > like incorrect handling of it in functions? Nope, at the moment all problems are fixed. AFAIK. Patch v021 is my final one, IMHO. Unless, you show unacceptable downsides in replacing raise_exception() with exitshell(). I hope this helps, -- Roberto A. Foglietta +39.349.33.30.697
exit_VS_exce.diff
Description: Binary data
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
