From 7c2dceaa70ac726735c7ae8d0b370c79746714b6 Mon Sep 17 00:00:00 2001 From: alexisVLRT Date: Fri, 7 May 2021 17:11:57 +0200 Subject: [PATCH] fix: issue where certain string would crash numeric checks --- bin/set_network.sh | 2 +- bin/set_project.sh | 2 +- bin/set_users.sh | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/set_network.sh b/bin/set_network.sh index 9bd109a..dd2e56f 100755 --- a/bin/set_network.sh +++ b/bin/set_network.sh @@ -30,7 +30,7 @@ else MAX_CHOICE=$((counter - 1)) read -p 'Please enter your numeric choice: ' NUMERIC_CHOICE - while (( NUMERIC_CHOICE < 1 )) || (( NUMERIC_CHOICE > MAX_CHOICE )) + while echo "$NUMERIC_CHOICE" | grep -vqE "^\-?[0-9]+$" || (( NUMERIC_CHOICE < 1 )) || (( NUMERIC_CHOICE > MAX_CHOICE )) do read -p "Please enter a value between 1 and $MAX_CHOICE: " NUMERIC_CHOICE done diff --git a/bin/set_project.sh b/bin/set_project.sh index 07d42a4..e97fb73 100755 --- a/bin/set_project.sh +++ b/bin/set_project.sh @@ -18,7 +18,7 @@ done MAX_CHOICE=$((counter - 1)) read -p 'Please enter your numeric choice: ' NUMERIC_CHOICE -while (( NUMERIC_CHOICE < 1 )) || (( NUMERIC_CHOICE > MAX_CHOICE )) +while echo "$NUMERIC_CHOICE" | grep -vqE "^\-?[0-9]+$" || (( NUMERIC_CHOICE < 1 )) || (( NUMERIC_CHOICE > MAX_CHOICE )) do read -p "Please enter a value between 1 and $MAX_CHOICE: " NUMERIC_CHOICE done diff --git a/bin/set_users.sh b/bin/set_users.sh index 9bf2b23..2fd8984 100755 --- a/bin/set_users.sh +++ b/bin/set_users.sh @@ -12,11 +12,11 @@ add_access () { MAX_CHOICE=$((counter - 1)) read -p 'Please enter your numeric choice: ' NUMERIC_CHOICE - while (( $NUMERIC_CHOICE < 1 )) || (( $NUMERIC_CHOICE > $MAX_CHOICE )) + while echo "$NUMERIC_CHOICE" | grep -vqE "^\-?[0-9]+$" || (( NUMERIC_CHOICE < 1 )) || (( NUMERIC_CHOICE > MAX_CHOICE )) do read -p "Please enter a value between 1 and $MAX_CHOICE: " NUMERIC_CHOICE done - NUMERIC_CHOICE="$(( $NUMERIC_CHOICE - 1 ))" + NUMERIC_CHOICE="$(( NUMERIC_CHOICE - 1 ))" } echo @@ -50,6 +50,7 @@ do fi fi fi + done IFS=',';WEB_APP_USERS=\'[${WEB_APP_USERS[*]}]\';IFS=$' \t\n'