From 44093314419e13f12b0a97883c2b96c7d20d70e1 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Sat, 19 Mar 2022 19:22:15 +0100 Subject: [PATCH] refactor(kiauh.sh): no global confirm / error message anymore Signed-off-by: Dominik Willner th33xitus@gmail.com --- kiauh.sh | 10 ++++------ scripts/klipper.sh | 11 +++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/kiauh.sh b/kiauh.sh index 73d9161..92692a3 100755 --- a/kiauh.sh +++ b/kiauh.sh @@ -118,23 +118,21 @@ print_msg(){ } print_error(){ - [ -z "${ERROR_MSG}" ] && return + [ -z "${1}" ] && return echo -e "${red}" echo -e "#########################################################" - echo -e " ${ERROR_MSG} " + echo -e " ${1} " echo -e "#########################################################" echo -e "${white}" - unset ERROR_MSG } print_confirm(){ - [ -z "${CONFIRM_MSG}" ] && return + [ -z "${1}" ] && return echo -e "${green}" echo -e "#########################################################" - echo -e " ${CONFIRM_MSG} " + echo -e " ${1} " echo -e "#########################################################" echo -e "${white}" - unset CONFIRM_MSG } clear_msg(){ diff --git a/scripts/klipper.sh b/scripts/klipper.sh index 9270eb6..4976d87 100644 --- a/scripts/klipper.sh +++ b/scripts/klipper.sh @@ -153,12 +153,11 @@ function klipper_setup(){ ### confirm message if [[ ${instances} -eq 1 ]]; then - CONFIRM_MSG="Klipper has been set up!" + local confirm="Klipper has been set up!" elif [[ ${instances} -gt 1 ]]; then - CONFIRM_MSG="${instances} Klipper instances have been set up!" + local confirm="${instances} Klipper instances have been set up!" fi - export CONFIRM_MSG - print_confirm && return + print_confirm "${confirm}" && return } function write_klipper_service(){ @@ -305,8 +304,8 @@ function remove_klipper(){ remove_klipper_dir remove_klipper_env - CONFIRM_MSG=" Klipper was successfully removed!" && print_confirm - export CONFIRM_MSG + local confirm="Klipper was successfully removed!" + print_confirm "${confirm}" && return } #================================================#