Oh, sorry. It should be

    g() { f; return; }

not

    g() { return; }

On Sun, Apr 19, 2020 at 9:20 AM Oğuz <[email protected]> wrote:
>
> > I have a question on the POSIX behavior of `return' shell builtin
> > without arguments when used in a shell `trap' action.
> > [...]
> > trap 'setexit 111; return' USR1
> > [...]
> > trap 'handler; stat=$?; return' USR1
>
> The same document you linked says:
>
> > If the shell is not currently executing a function or dot script, the
> > results are unspecified.
>
> in DESCRIPTION section; it's unspecified what those returns do.
>
> I got what you're actually asking though. According to the
> standard, application below should print kill's exit status bacause
> it is *the command that executed immediately preceding the trap
> action*.
>
>     f() { return 42; }
>     g() { return; }
>     trap 'g; echo $?' USR1
>     kill -USR1 $$
>
> However some shells (dash for instance) print 42. I think it's a
> misreading of the standard.
>
> --
> Oğuz



-- 
Oğuz

Reply via email to