Timeline for Error exit script from within command substitution
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 9, 2023 at 15:35 | comment | added | OrangeDog | @pfnuesel that doesn't work for errors in command substitutions | |
| Sep 6, 2019 at 11:41 | answer | added | Juergen | timeline score: 3 | |
| May 2, 2018 at 11:59 | comment | added | Ali Sadik Kumlali | set -e and echo "error" >&2 ; exit 1; works for me. It first prints "error" then exits. | |
| Jan 21, 2016 at 22:39 | answer | added | Hauke Laging | timeline score: 4 | |
| Jan 21, 2016 at 21:53 | comment | added | Wildcard | @AndyDalton, thanks, but I know that...I said it fails to work as intended, not that it fails to work as expected (and I mentioned the subshell issue). I want to know how to make it work as intended. | |
| Jan 21, 2016 at 21:50 | comment | added | Andy Dalton | In some_other_function you have local anothervar=$(myfunction). The $(myfunction) runs in a separate instance of the shell. The exit in myfunction exits that subshell, not the "parent" shell. | |
| Jan 21, 2016 at 21:49 | comment | added | pfnuesel | If you want to exit for every error that happens in your script, you can set -e. | |
| Jan 21, 2016 at 21:42 | history | asked | Wildcard | CC BY-SA 3.0 |