diff --git a/scripts/.fonctions b/scripts/.fonctions index 4dda5a1..5268a86 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -202,3 +202,15 @@ BACKUP_BEFORE_UPGRADE () { # Backup the current version of the app, restore it i 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 +}