Bash yes/no prompt function and password prompt with input masking

# Bash Y/n ask function
# Use: 
# if ask "Do you want to continue?"; then
#   echo "Yes"
# else
#   echo "No"
# fi
function ask {  
  read -p "$1 [Y/n] " -n 1 -r
  if [[ $REPLY =~ ^[Yy]$ ]]; then
    echo
    return 0
  elif [[ $REPLY = '' ]]; then
    return 0
  else
    echo
    return 1
  fi
}

Prompt for password with input masking:

# Bash password prompt function with input masking
# Use:
# ask_pass "Enter the password: "
# password="$REPLY"
function ask_pass {
  REPLY=""
  prompt="$1"
  while IFS= read -p "$prompt" -r -s -n 1 char
  do
    if [[ $char == $'\0' ]]; then
      break
    fi
    prompt='*'
    REPLY+="$char"
  done
  echo
}