kkimurak / ssl-setup

Bash script that setup the official RoboCup-SSL tools with required packages ( https://github.com/RoboCup-SSL/ )
4 stars 0 forks source link

flag "-e" not working (not stopping at error) #26

Closed kkimurak closed 4 years ago

kkimurak commented 4 years ago

Currently I'm setting the flag set -Ceu.

I think option -e will check the exit code for each line,
and I added || echo "error message for line" for end of most of lines.
It will returns non-error value, so option -e may not work.

BTW, I've added function error_end() to script. it shows error message and exit with 1. I can use this.

kkimurak commented 4 years ago

To solve this problem, I have an idea to enhance error_end() to works with arguments.

e.g.

# param $1 : exit code of process that fails
# param $2 : error message
function error_end() {
    echo "[ERROR] $2"
    echo "[ERROR] process exits with code $1"
    echo "[ERROR] Installation incomplete."
    exit $1
}

something_may_cause_error || error_end "process something_may_cause_error failed." $?