From: tshenry Date: Sat, 9 Jan 2021 05:08:05 +0000 (-0800) Subject: FEATURE: Add validation to admin email prompt in discourse-setup (#514) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3d34d9899284267ffec3fe673a18fd945a41edb0;p=discourse_docker.git FEATURE: Add validation to admin email prompt in discourse-setup (#514) --- diff --git a/discourse-setup b/discourse-setup index ec1adaf..b4472a6 100755 --- a/discourse-setup +++ b/discourse-setup @@ -383,11 +383,25 @@ ask_user_for_config() { if [ ! -z "$developer_emails" ] then - read -p "Email address for admin account(s)? [$developer_emails]: " new_value - if [ ! -z "$new_value" ] - then - developer_emails="$new_value" - fi + local email_valid="n" + until [ "$email_valid" == "y" ] + do + read -p "Email address for admin account(s)? [$developer_emails]: " new_value + if [ ! -z "$new_value" ] + then + if [[ ${#new_value} -ge 7 && $new_value == *@* ]] + then + developer_emails="$new_value" + email_valid="y" + else + echo + echo "[Error] Invalid email address" + echo + fi + else + email_valid="y" + fi + done fi if [ ! -z "$smtp_address" ]