fix: dialog allowed a higher option than actually possible

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-04-17 18:59:11 +02:00
parent 02d0ce8a78
commit f362cdce8f

View File

@@ -13,7 +13,7 @@ set -e
function change_klipper_repo_menu(){
local repo_file="${SRCDIR}/kiauh/klipper_repos.txt"
local url branch i=0
local url branch
top_border
echo -e "| ~~~~~~~~ [ Set custom Klipper repo ] ~~~~~~~~ | "
@@ -27,19 +27,12 @@ function change_klipper_repo_menu(){
while IFS="," read -r col1 col2; do
url+=("${col1}")
branch+=("${col2}")
i=$((i+1))
done < <(grep "" "${repo_file}" | tail -n "+12")
done < <(grep "" "${repo_file}" | tail -n "+11")
while true; do
read -p "${cyan}Select Klipper repo:${white} " option
if [ "${option}" = "b" ] || [ "${option}" = "B" ]; then
clear && print_header
settings_menu
break
elif [ "${option}" = "h" ] || [ "${option}" = "H" ]; then
clear && print_header
show_custom_klipper_repo_help
elif [ "${option}" -le ${#url[@]} ]; then
read -p "${cyan}Perform action:${white} " option
case "${option}" in
0 | "$((option < ${#url[@]}))")
if [ -d "${KLIPPER_DIR}" ]; then
top_border
echo -e "| ${red}!!! ATTENTION !!!${white} |"
@@ -67,12 +60,18 @@ function change_klipper_repo_menu(){
set_custom_klipper_repo "${url[${option}]}" "${branch[${option}]}"
ok_msg "This repo will now be used for new Klipper installations!\n"
fi
break
else
break;;
B|b)
clear && print_header
print_error "Invalid command!"
change_klipper_repo_menu
fi
settings_menu
break;;
H|h)
clear && print_header
show_custom_klipper_repo_help
break;;
*)
error_msg "Invalid command!";;
esac
done
}
@@ -95,9 +94,10 @@ function switch_klipper_repo(){
url=${1} branch=${2}
status_msg "Switching Klipper repository..."
do_action_service "stop" "klipper"
cd ~ && rm -rf "${KLIPPER_DIR}"
git clone "${url}" && cd "${KLIPPER_DIR}"
git checkout "${branch}" && cd ~
cd "${HOME}"
[ -d "${KLIPPER_DIR}" ] && rm -rf "${KLIPPER_DIR}"
git clone "${url}" "klipper" && cd "${KLIPPER_DIR}"
git checkout "${branch}" && cd "${HOME}"
do_action_service "start" "klipper"
}