Skip to content

Commit

Permalink
fix: issue where certain string would crash numeric checks
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisVLRT committed May 7, 2021
1 parent 59b0458 commit 7c2dcea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/set_network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/set_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions bin/set_users.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,6 +50,7 @@ do
fi
fi
fi

done

IFS=',';WEB_APP_USERS=\'[${WEB_APP_USERS[*]}]\';IFS=$' \t\n'
Expand Down

0 comments on commit 7c2dcea

Please sign in to comment.