From: Denys Vlasenko <vda.linux@googlemail.com>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>,
DASH shell mailing list <dash@vger.kernel.org>
Subject: Re: shell script error management in busybox ash
Date: Wed, 15 Sep 2021 22:22:41 +0200 [thread overview]
Message-ID: <CAK1hOcPMDnxZZ=cpSR-sVnfA8Cdno_QFO=OT6QXRjOKOOEPSQA@mail.gmail.com> (raw)
In-Reply-To: <6f4b5c87-a7ef-a80b-2230-de4c7d540318@gigawatt.nl>
On Wed, Sep 15, 2021 at 10:16 PM Harald van Dijk <harald@gigawatt.nl> wrote:
> >>> 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
>
> For bash, it depends on how the shell is invoked. When bash reads
> commands from stdin, it prints trap:f. When bash is called with that
> exact same script passed as -c, it prints trap:. There may be a more
> specific option that can control this.
Indeed. In -c, it prints "trap:"
In a script, it prints "trap:f"
Looks quite inconsistent.
Well, in this case I'd fall back to "what would be the most _useful_
behavior". Losing information in which function "exit" was is less useful.
I prefer passing it to EXIT trap.
prev parent reply other threads:[~2021-09-15 20:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 17:47 shell script error management in busybox ash Roberto A. Foglietta
2021-09-15 19:47 ` Denys Vlasenko
2021-09-15 19:59 ` Harald van Dijk
2021-09-15 20:07 ` Denys Vlasenko
2021-09-15 20:16 ` Harald van Dijk
2021-09-15 20:22 ` Denys Vlasenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK1hOcPMDnxZZ=cpSR-sVnfA8Cdno_QFO=OT6QXRjOKOOEPSQA@mail.gmail.com' \
--to=vda.linux@googlemail.com \
--cc=dash@vger.kernel.org \
--cc=harald@gigawatt.nl \
--cc=roberto.foglietta@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).