Created
March 8, 2013 23:58
-
-
Save guumaster/5121476 to your computer and use it in GitHub Desktop.
Read password from stdin
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 | |
unset password | |
prompt="Secret Password:" | |
while IFS= read -p "$prompt" -r -s -n 1 char | |
do | |
if [[ $char == $'\0' ]] | |
then | |
break | |
fi | |
#prompt='*' # to show * for every keystroke | |
prompt='' | |
password+="$char" | |
done | |
#echo "your password is: $password" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment