On Sat, Sep 4, 2021 at 8:39 PM Roberto A. Foglietta <
[email protected]> wrote:
>
> > Can this be reasonably split up, or it is too interrelated?
>>
>> E.g. add FUNCNAME in a separate patch?
>> Add set -E in a separate patch?
>
>  They are interrelated but there is a more specific reason to maintain
then all together:
>
>  - trap ERR requires set -E to let functions inherit the trap
>  - global LINENO requires global FUNCNAME because functions might be
sourced by a file
>
>  Moreover, who uses trap ERR does it because s/he wants to be
acknowledged of any error otherwise s/he would use set -e.
>  Being acknowledged for error requires LINENO and FUNCNAME thus all these
functionalities achieve a higher level goal: error management/debug in
shell scripting.

The patches are split up to make understanding them easier,
not because the features they add are orthogonal.

trap "ERR" does not _have to_ have FUNCNAME or set -E.


>> >  The patch is in attachment with its test suite.
>>
>> Can you git send-email the patches?
>
>
> Uhm, I will try it. After all it is just a matter of using a tool instead
of another.

I meant that replying to "git send-email"ed patch is easier


>>  #define linenovar     (G_var.linenovar    )
>> +#define funcnamevar   (G_var.funcnamevar  )
>> +#define funcname      (G_var.funcname     )
>> +#define doingtrap        (G_var.doingtrap    )
>>
>> Inconsistent whitespace
>
> I am confused because the image inlined here below shows that they are
correctly aligned with a fixed font text editor.

You have "#define doingtrap<TAB><SPACE><SPACE>(G_var.doingtrap    )" there.


>> What does doingtrap do? Inhibits line counting?
>> In this case, you don't need to save/restore lineno?
>
> Nope, save/restoring lineno is done elsewhere only when required.
> It is enough to not change the lineno during the evaluation of a trap.

I'm asking why do you do this:

+                                               savelineno = lineno;
+                                               doingtrap = 1;
...
+                                       }
...
+                                       lineno = savelineno;

With doingtrap = 1, linenos should not be counting anyuway. So why
save/restore?


>> It seems you can replace the above save/restore of doingtrap
>> if you change it from bool to counter?
>
>  The boolean doingtrap = 1 avoids lineno increasing inside ANY traps.
>  It does a single thing in the simplest way and this is enough for every
case.

    static bool savetrap;
    ...
    savetrap = doingtrap;
    doingtrap = 1;
    ...
    doingtrap = savetrap;

looks more complicated (and needs a static) than

    doingtrap++;
    ...
    doingtrap--;

to me.
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to