Skip to content

Instantly share code, notes, and snippets.

@binaryben
Created January 25, 2018 12:34
Show Gist options
  • Save binaryben/8b7498458dc4d9e547c89ece43819222 to your computer and use it in GitHub Desktop.
Save binaryben/8b7498458dc4d9e547c89ece43819222 to your computer and use it in GitHub Desktop.
Bash password prompt
#!/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