Eco os caracteres inseridos como asteriscos? Jon Red ficou em primeiro lugar, mas aqui está outro:
#!/bin/bash
# read a string, prompting using "$1"
# echo characters entered as asterisks
# value is returned in variable 'pass'
readpw() {
printf "%s" "${1-}"
pass=
local char
while IFS= read -r -s -n1 char; do
if [[ $char = "" ]] ; then
# enter, end
printf "\n"
break
elif [[ $char = $'7' ]] ; then
# backspace, remove one char
if [[ $pass != "" ]] ; then
pass=${pass%?}
printf '\b \b'
fi
else
# any other char
pass+=$char
printf "*"
fi
done
}
readpw "Enter Password: "
printf "Password entered was: %s\n" "$pass"