From 0440ce149b494d81785a450e5077aeb039ba7cb2 Mon Sep 17 00:00:00 2001 From: Martin Wimpress Date: Tue, 2 Jul 2024 14:06:20 +0100 Subject: [PATCH] refactor: remove single use error_ functions --- quickget | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/quickget b/quickget index 1712d44..723666b 100755 --- a/quickget +++ b/quickget @@ -182,13 +182,6 @@ function error_specify_release() { exit 1 } -function error_specify_edition() { - show_os_info "${OS}" - echo -e " - Editions:\t$("editions_${OS}" | fold -s -w "$(tput cols)")" - echo -e "\nERROR! You must specify an edition." - exit 1 -} - function error_not_supported_release() { if [[ ! "${RELEASES[*]}" =~ ${RELEASE} ]]; then echo -e "ERROR! ${DISPLAY_NAME} ${RELEASE} is not a supported release.\n" @@ -198,18 +191,6 @@ function error_not_supported_release() { fi } -function error_not_supported_edition() { - if [[ ! "${EDITIONS[*]}" = *"${EDITION}"* ]]; then - echo -e "ERROR! ${EDITION} is not a supported $(pretty_name "${OS}") edition\n" - echo -n ' - Supported editions: ' - for EDITION in "${EDITIONS[@]}"; do - echo -n "${EDITION} " - done - echo "" - exit 1 - fi -} - function error_not_supported_lang() { echo -e "ERROR! ${I18N} is not a supported $(pretty_name "${OS}") language\n" echo -n ' - Editions: ' @@ -3487,9 +3468,20 @@ if [ -n "${2}" ]; then EDITIONS=("$(editions_"${OS}")") if [ -n "${3}" ]; then EDITION="${3}" - error_not_supported_edition + if [[ ! "${EDITIONS[*]}" = *"${EDITION}"* ]]; then + echo -e "ERROR! ${EDITION} is not a supported $(pretty_name "${OS}") edition\n" + echo -n ' - Supported editions: ' + for EDITION in "${EDITIONS[@]}"; do + echo -n "${EDITION} " + done + echo "" + exit 1 + fi else - error_specify_edition + show_os_info "${OS}" + echo -e " - Editions:\t$("editions_${OS} | fmt -w 80")" + echo -e "\nERROR! You must specify an edition." + exit 1 fi handle_missing VM_PATH="${OS}-${RELEASE}-${EDITION}"