From 9aa724482440f369871576cc54fa7a5168041799 Mon Sep 17 00:00:00 2001 From: levasseur Date: Wed, 8 Sep 2021 18:11:24 +0200 Subject: [PATCH] added noerror function to execute stuff outside of error control system --- lib/aaa_errors.sh | 14 ++++++++++++++ modules/upgrade_dist.sh | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/aaa_errors.sh b/lib/aaa_errors.sh index 8050a7b..645e12c 100644 --- a/lib/aaa_errors.sh +++ b/lib/aaa_errors.sh @@ -81,6 +81,20 @@ function backtrace } +# ------------------------------------------------------------------------------ +# Execute command outside of error control +noerror() +{ + set +o errexit + trap - ERR + + $@ + + trap "error ${LINENO}" ERR + set -o errexit +} + + # ------------------------------------------------------------------------------ # Test and exit if not root (or any UID 0 user) check_root() diff --git a/modules/upgrade_dist.sh b/modules/upgrade_dist.sh index 78772c0..9e49a45 100644 --- a/modules/upgrade_dist.sh +++ b/modules/upgrade_dist.sh @@ -47,7 +47,7 @@ upgrade_dist() precheck_upgrade_dist() { prnt I "Vérification du réseau..." - wget -q --tries=10 --timeout=20 --spider http://www.cnrs.fr + noerror wget -q --tries=10 --timeout=20 --spider http://www.cnrs.fr if [[ ! $? -eq 0 ]]; then prnt E "Réseau non fonctionnel ! Abandon." die 160