Timeline for BASH: Change exit status in trap
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 18 at 14:30 | comment | added | Alex Martian |
"Normal commands, whether fail or succeed, won't change the exit status.". Indeed, the "The Open Group Base Specifications" linked in the answer states The value of "$?" after the trap action completes shall be the value it had before the trap action was executed.
|
|
| Oct 6, 2023 at 16:30 | comment | added | superbatfish |
Apparently if you use set -e in your script, then errors in the trap will be returned to the caller. For example, try this command with and without the -e part: bash -e -c "trap 'false' EXIT"; echo $?
|
|
| Sep 3, 2021 at 2:51 | history | became hot network question | |||
| Sep 2, 2021 at 23:35 | vote | accept | Zoltan K. | ||
| Sep 2, 2021 at 20:39 | answer | added | user313992 | timeline score: 9 | |
| Sep 2, 2021 at 19:26 | answer | added | ilkkachu | timeline score: 1 | |
| Sep 2, 2021 at 18:51 | history | asked | Zoltan K. | CC BY-SA 4.0 |