refactor: add input validation to mainsail/fluidd port selection

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-05-22 16:17:55 +02:00
parent ab2d804d19
commit 6902dd90db
2 changed files with 9 additions and 10 deletions

View File

@@ -487,7 +487,6 @@ function mainsail_port_check() {
}
function select_mainsail_port() {
local new_port
if [[ ${PORT_80_BLOCKED} == "true" ]]; then
echo
top_border
@@ -505,8 +504,9 @@ function select_mainsail_port() {
echo -e "| Be aware: there is ${red}NO${white} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
#TODO implement regex input validation for numbers only
local new_port re="^[0-9]+$"
while [[ ! ${new_port} =~ ${re} ]]; do
read -p "${cyan}Please enter a new Port:${white} " new_port
if [[ ${new_port} != "${FLUIDD_PORT}" ]] && [[ ${new_port} != "${OCTOPRINT_PORT}" ]]; then
echo "Setting port ${new_port} for Mainsail!"