From 2c27e1d7b75f3bffbb8ac0952155bde4ab1c2f3a Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sun, 18 Jun 2017 00:02:47 +0200 Subject: [PATCH] [fix] add ynh_abort_if_errors on generic function --- scripts/_common.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7b74120..e8691e2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -341,4 +341,15 @@ ynh_backup_before_upgrade () { # Backup the current version of the app, restore else # Si le backup a échoué ynh_die "Backup failed, the upgrade process was aborted." fi +} + +# Exit if an error occurs during the execution of the script. +# +# Stop immediatly the execution if an error occured or if a empty variable is used. +# The execution of the script is derivate to ynh_exit_properly function before exit. +# +# Usage: ynh_abort_if_errors +ynh_abort_if_errors () { + set -eu # Exit if a command fail, and if a variable is used unset. + trap ynh_exit_properly EXIT # Capturing exit signals on shell script } \ No newline at end of file