Re: shell script error management in busybox ash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 15, 2021 at 9:59 PM Harald van Dijk <harald@xxxxxxxxxxx> wrote:
> On 15/09/2021 20:47, Denys Vlasenko wrote:
> > On Wed, Sep 15, 2021 at 7:48 PM Roberto A. Foglietta
> > <roberto.foglietta@xxxxxxxxx> wrote:
> >> Moreover,
> >> the code that these exceptions trigger (everywhere the setjmp()
> >> returns true) restores some values and frees some memory but the traps
> >> need the information before the restore, not the restored values.
> >
> > Yes, _this_ is the problem we are having.
> >
> > E.g. $FUNCNAME in EXIT trap needs to be current function's name.
>
> Important to also mention that although FUNCNAME is not part of POSIX,
> and there is no spec to compare to, in bash and ksh it does not behave
> that way

In my testing, it does.

> so you're talking about implementing FUNCNAME in a way that is
> incompatible with existing shells.

Try this in bash:

  trap 'echo trap:$FUNCNAME' EXIT
  f() { exit; }
  f

I'm getting:
  trap:f

IOW: in EXIT trap, $FUNCNAME is the name of the function where "exit"
was invoked.

$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-redhat-linux-gnu)



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux