bug-bash
[Top][All Lists]
Advanced

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

Re: EXIT trap is not executed after an exec failure in a non-interactive


From: Alex fxmbsw7 Ratchev
Subject: Re: EXIT trap is not executed after an exec failure in a non-interactive shell
Date: Fri, 1 Oct 2021 01:46:59 +0200

i think its not a bug but normal runtime
as ive understood, exec 'replaces' itself with <binary path arg>, then no
more continued code
well error checking could maybe be better


On Fri, Oct 1, 2021, 01:25 Mark March <march@systempad.org> wrote:

> If execfail is set, a failed exec does not cause a non-interactive shell
> to exit, but it seems to reset the EXIT trap:
>
> cat <<'EOF' | bash
> shopt -s execfail
> trap "echo exiting..." EXIT
> exec ~/does-not-exist
> echo "exec failed in bash-$BASH_VERSION"
> exit 1
> EOF
>
> Output:
>
> bash: line 3: /home/march/does-not-exist: No such file or directory
> exec failed in bash-5.0.17(1)-release
>
> The "exiting..." line is missing. If you comment out exec
> ~/does-not-exist, "exiting..." will be printed as expected.
> I get this under 5.1.8 as well, built with gcc 9.3 This is on Ubuntu 20 on
> x86_64.
>
> -Mark
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]