From 14c06c8b8722f73bb23b3d923d7af97a80a96ea8 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 2 Dec 2020 15:58:35 +0100 Subject: [PATCH] Add error_message function --- qb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/qb b/qb index 6b57738..69c6c90 100755 --- a/qb +++ b/qb @@ -69,6 +69,17 @@ debug_message() { # {{{ return 0 } # }}} +error_message() { # {{{ + + local_error_message="${1}" + local_error_code="${2}" + + ## Print message if DEBUG is enable (=0) + [ "${DEBUG}" -eq "0" ] && printf '%b\n' "ERROR − ${PROGNAME} : ${RED}${local_error_message}${RESET}" + + exit "${local_error_code:=66}" +} +# }}} is_proc_running() { # {{{ local_proc_pattern="${1}" @@ -212,12 +223,9 @@ main() { # {{{ define_vars ## Try to get a working qutebrowser binary - ### Or exit with error + ### Or exit with error message and code 1 get_qutebrowser_bin \ - || debug_message "main − \ -Can't find a working qutebrowser binary." \ - || exit 2 - + || error_message "Can't find a working qutebrowser binary." "1" ## If nothing related to Qutebrowser is currently running ### Try to start qutebrowser