Last active
May 7, 2021 08:20
-
-
Save GlitchedPolygons/8e2e6df19c9ff108b7f47429589b7ca3 to your computer and use it in GitHub Desktop.
Linux CLI shell script snippet for prompting the user for a password (with confirmation and empty-check).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while true; do | |
echo | |
read -s -p "Enter the desired password: " PASSWORD | |
echo | |
read -s -p "Confirm your password by re-entering it again: " PASSWORD_CONFIRMATION | |
echo | |
[ "$PASSWORD" = "$PASSWORD_CONFIRMATION" ] && break || echo " ----- The two entered passwords don't match; please try again! -----" | |
done | |
if [ -z "$PASSWORD" ]; then | |
echo | |
echo "ERROR: Password can't (and shouldn't...) be empty! Please provide a valid value!" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment