From 7ba5ab206720782120185352a632772a1a1e392d Mon Sep 17 00:00:00 2001 From: Menno van Leeuwen Date: Fri, 8 Nov 2024 14:07:54 +0100 Subject: [PATCH] improves input validation in create_hardware_config function --- setup.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index c4dbb3e..a29aba4 100755 --- a/setup.sh +++ b/setup.sh @@ -56,12 +56,16 @@ create_hardware_config() { echo "Is this a server or workstation? (s/w)" tput sgr0 - read systemType - while [[ $systemType != "s" && $systemType != "w" ]]; do - echo "Invalid input. Please enter 's' for server or 'w' for workstation:" - read systemType + while true; do + read -p "(s/w): " systemType + if [[ $systemType == "s" || $systemType == "w" ]]; then + break + fi + + echo "Invalid input. Please enter 's' for server or 'w' for workstation." done + if [ $systemType == "s" ]; then isServer="true" isWorkstation="false"