Created
January 25, 2018 12:34
-
-
Save binaryben/8b7498458dc4d9e547c89ece43819222 to your computer and use it in GitHub Desktop.
Bash password prompt
This file contains 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
#!/bin/bash | |
function PWDprompt { | |
read -sp 'Password: ' pass1 | |
echo | |
read -sp "Confirm: " pass2 | |
if [[ "$pass1" == "$pass2" ]] | |
then | |
if test -z $pass1 | |
then | |
echo -e "\n\nERROR: Password cannot be empty\n" | |
PWDprompt | |
else | |
let PWD=$pass1 | |
echo "" | |
fi | |
else | |
echo -e "\n\nERROR: Passwords do not match\n" | |
PWDprompt | |
fi | |
} | |
PWDprompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment