Timeline for Trap, ERR, and echoing the error line
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 7, 2022 at 12:47 | comment | added | RichVel |
@MestreLion - updated answer to include -E in 'unofficial strict mode', good tip!
|
|
| Jul 11, 2022 at 14:27 | history | edited | RichVel | CC BY-SA 4.0 |
Fix for code - ensure all output goes to standard error so it's usable inside a shell pipeline
|
| Jul 9, 2022 at 6:20 | history | edited | RichVel | CC BY-SA 4.0 |
added -E option to mention of unofficial strict mode
|
| Aug 15, 2020 at 7:06 | comment | added | MestreLion |
Yeah, just noticed that. That builtin message is enough for me. By the way, you might add -E to your "unofficial strict mode" so the trap also catches errors inside functions. My final strict mode became set -Eeuo pipefail
|
|
| Aug 15, 2020 at 6:09 | comment | added | RichVel |
I don't know of a way to trap the undefined var error, which seems to be detected without firing this trap. However, the built-in error message is quite clear and has a line number: foo.sh: line 7: x: unbound variable.
|
|
| Aug 15, 2020 at 4:29 | comment | added | MestreLion |
Loved the mention about set -euo pipefail!!! But... is there any way to trap the undefined var case?
|
|
| Jun 4, 2019 at 11:46 | history | edited | RichVel | CC BY-SA 4.0 |
link for bash 'unofficial strict mode'
|
| Jun 4, 2019 at 11:19 | history | answered | RichVel | CC BY-SA 4.0 |