trap overwrites last exit code

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

 



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





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

  Powered by Linux