[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
EXIT trap is not executed after an exec failure in a non-interactive she
From: |
Mark March |
Subject: |
EXIT trap is not executed after an exec failure in a non-interactive shell |
Date: |
Thu, 30 Sep 2021 23:24:20 +0000 (UTC) |
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
- EXIT trap is not executed after an exec failure in a non-interactive shell,
Mark March <=