I declare a `my_die() { echo "$" 1>&2; exit 1; }` on top of each file. Makes life easier by knowing why the script failed instead of having only exit code or having to turn `set -x` on and rerun.
Only if I could somehow mix `if` & `set -e`in a readable way... I wanted it to only capture errors of explicit `return 1` from bash functions, not from commands within those bash functions. But I guess I'm doing too much* of the job in bash now and it's getting messy.
moebrowne 1 hours ago [-]
I believe that Bash scripts should be trivially short and simple. As soon as any complexity is introduced they should be written in another language.
general1465 1 hours ago [-]
I agree, the moment bash script needs "if" statement, you are using wrong language.
vdm 3 hours ago [-]
> We can assign the value of $? to an environment variable
Only if I could somehow mix `if` & `set -e`in a readable way... I wanted it to only capture errors of explicit `return 1` from bash functions, not from commands within those bash functions. But I guess I'm doing too much* of the job in bash now and it's getting messy.
exit_code is not an environment variable?
https://www.gnu.org/software/bash/manual/html_node/Shell-Par...