[PATCH] shell script error management in ash (set of 6 patches)
Roberto A. Foglietta
roberto.foglietta at gmail.com
Tue Aug 24 10:10:18 UTC 2021
Il giorno mar 24 ago 2021 alle ore 00:00 Harald van Dijk <harald at gigawatt.nl>
ha scritto:
> On 23/08/2021 11:50, Roberto A. Foglietta wrote:
> > Il giorno lun 23 ago 2021 alle ore 11:15 Harald van Dijk
> > <harald at gigawatt.nl <mailto:harald at gigawatt.nl>> ha scritto:
> >
> > On 23/08/2021 10:09, Roberto A. Foglietta wrote:
> > > Il giorno lun 23 ago 2021 alle ore 10:45 Harald van Dijk
> > > <harald at gigawatt.nl <mailto:harald at gigawatt.nl>
> > <mailto:harald at gigawatt.nl <mailto:harald at gigawatt.nl>>> ha scritto:
> > >
> > > On 23/08/2021 09:16, Roberto A. Foglietta wrote:
> >
> > > I did the same.
> >
> > You changed command eval false to false, but the 'command' builtin
> was
> > the key element there, that is what made the syntax error non-fatal.
> > 'command eval false' is not the same thing as simply 'false' (at
> least
> > not in busybox ash).
> >
> >
> > Hi Harald, thanks to your deep knowledge of the shell we finally reached
> > the point!
> >
> > The attached patch solves two questions/issues:
> >
> > - not exit exceptions disables trap ERR (solved)
> > - not exit exceptions might do memory leak (not the case, verified)
>
> Sorry, but this approach cannot work. The fact that an exception was
> raised and handled does not tell you where it was handled, it does not
> tell you whether the handler is still active.
>
> Consider:
>
> trap '
> command eval ")"
> false
> ' ERR
> false
> echo done
>
Thanks again for your insightfulness.
I reverted back to the previous situation when I was resetting the
recursive flag when the evaltree returns:
- if evaltree returns: no problem
- before an not-exit not-returning exception is raised, it sets an handler
that makes it returning
Moreover, I used static variables to save the previous state in such a way
I am able to set back again in case my handler takes off.
I have updated the testsuite and moved the test9.sh in testD.sh plus
testD.sh makes the check of the last case you arise to my attention.
The full patch is here:
https://github.com/robang74/tinycore-editor/tree/main/busybox/patches
busybox-1.33.1-error-management-extension-for-ash-v017.patch
Best regards,
--
Roberto A. Foglietta
+39.349.33.30.697
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20210824/59de68f2/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox-1.33.1-not-returning-handlers-return-by-handler.patch
Type: application/octet-stream
Size: 1326 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20210824/59de68f2/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testsuite.tgz
Type: application/x-compressed
Size: 3091 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20210824/59de68f2/attachment-0001.bin>
More information about the busybox
mailing list