dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Patrick Brünn" <P.Bruenn@beckhoff.com>
To: "dash@vger.kernel.org" <dash@vger.kernel.org>
Subject: trap overwrites last exit code
Date: Thu, 6 May 2021 09:55:28 +0000	[thread overview]
Message-ID: <7ee35167691c1b1e42100f91842f07cbe817b337.camel@beckhoff.com> (raw)

Hello list,

Since we are migrating to Debian bullseye, we discovered a new behavior
with our scripts, which look like this:
>#!/bin/sh
>cleanup() {
>        set +e
>        rmdir ""
>}
>set -eu
>trap 'cleanup' EXIT INT TERM
>echo 'Hello world!'

With old dash v0.5.10.2 this script would return 0 as we expected it.
But since commit 62cf6955f8abe875752d7163f6f3adbc7e49ebae it returns
the last exit code of our cleanup function.
Reverting that commit gives a merge conflict, but it seems to fix _our_
problem. As that topic appears too complex to us I want to ask the
experts here:

Is this change in behavior intended, by dash?

Our workaround at the moment would be:
>trap 'cleanup || true' EXIT INT TERM

Comments on our usage of traps are welcome, too.

Thanks and best regards,
Patrick
Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075


             reply	other threads:[~2021-05-06 10:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06  9:55 Patrick Brünn [this message]
2021-05-17  7:19 ` eval: Do not cache value of eflag in evaltree Herbert Xu
2021-05-19  8:08   ` Patrick Brünn

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=7ee35167691c1b1e42100f91842f07cbe817b337.camel@beckhoff.com \
    --to=p.bruenn@beckhoff.com \
    --cc=dash@vger.kernel.org \
    /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).