feat: Move not supported edition message into function

This commit is contained in:
zen0bit 2024-04-13 22:46:14 +02:00
parent bea27b1ffa
commit cb33fa0bc8
1 changed files with 13 additions and 7 deletions

View File

@ -3443,6 +3443,18 @@ fi
LANGS=() LANGS=()
os_supported_edition() {
if [[ ! " ${EDITIONS[*]} " =~ " ${EDITION} " ]]; then
echo -e "ERROR! ${EDITION} is not a supported $(pretty_name "${OS}") edition\n"
echo -n ' - Editions: '
for EDITION in "${EDITIONS[@]}"; do
echo -n "${EDITION} "
done
echo ""
exit 1
fi
}
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
OS="${1,,}" OS="${1,,}"
if [ "${OS}" == "list" ] || [ "${OS}" == "list_csv" ]; then if [ "${OS}" == "list" ] || [ "${OS}" == "list_csv" ]; then
@ -3488,13 +3500,7 @@ if [ -n "${2}" ]; then
EDITION=${EDITIONS[0]} EDITION=${EDITIONS[0]}
if [ -n "${3}" ]; then if [ -n "${3}" ]; then
EDITION="${3}" EDITION="${3}"
if [[ ! " ${EDITIONS[*]} " =~ " ${EDITION} " ]]; then os_supported_edition
echo -e "ERROR! ${EDITION} is not a supported $(pretty_name "${OS}") edition:\n"
for EDITION in "${EDITIONS[@]}"; do
echo -n "${EDITION} "
done
exit 1
fi
else else
echo -en "ERROR! You must specify an edition.\n - Editions: " echo -en "ERROR! You must specify an edition.\n - Editions: "
editions_"${OS}" editions_"${OS}"