Skip to content

Instantly share code, notes, and snippets.

@wcDogg
Last active September 7, 2022 04:18
Show Gist options
  • Save wcDogg/1d289b5c3613f9744f9fd3b9c884ab6a to your computer and use it in GitHub Desktop.
Save wcDogg/1d289b5c3613f9744f9fd3b9c884ab6a to your computer and use it in GitHub Desktop.
Bash: Create Password Prompt

Bash: Create Password Prompt

  • Prompt user to create and confirm a new password.
  • Cannot be blank.
  • Hide user's entry.
while :     
do
  read -rs -p "${QUEST} Admin PW: " NETWORK_PW && echo
  read -rs -p "${QUEST} Confirm admin PW: " NETWORK_PW_CONF && echo
  printf "\n"

  if [[ -z "$NETWORK_PW" || -z "$NETWORK_PW_CONF" ]]; then
    echo "${ERROR} Password cannot be blank." >&2
    continue
  elif [[ "$NETWORK_PW" == "$NETWORK_PW_CONF" ]]; then
    break; 
  fi
  echo "${ERROR} Passwords do not match." >&2  
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment