Last active
January 2, 2016 07:29
-
-
Save coderofsalvation/8270449 to your computer and use it in GitHub Desktop.
get password bashfunction
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
# prompts user to enter password | |
promptpasswd() | |
{ | |
if [ -n "$1" ]; then | |
_getpasswd_var_option=$(printf "%s\\n" "$1" | tr '[:upper:]' '[:lower:]') | |
printf "%s" "Enter your $_getpasswd_var_option password: " | |
stty -echo | |
read ${_getpasswd_var_option}passwd | |
stty echo | |
printf "\\n" | |
else | |
printf "%s" "Enter your password: " | |
stty -echo | |
read passwd | |
stty echo | |
printf "\\n" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment