set -e
retry() {
until "$@"
do
sleep 1
done
}
f() {
false
echo oh no
}
retry f
# oh no
set -e is ignored when a function executes in the context of a predicate.Shell scripts are great for when you just need to run stuff. If something bad happens you notice it and run another command to ameliorate the error. This is how most interactive shell sessions pan out.
As soon as you need to handle errors programmatically I heartily suggest that you switch to a language with fewer quirks than sh.