Loading...

Exit always called - variable precedence

Answer #1 100 %

You can do it like this :

if [[ "$x" -ge 1 && "$x" -le 4 ]]; then
    /export/home/scripts/script1.sh \
    "$x" \
    || { echo "Error.. something went wrong." && exit 1 ; }
fi

Note : I used { ; }, instead of (), because () will open your command in a subshell, so it will not exit.

Tags: bash

You’ll also like:


© 2022 CodeForDev.com -