# yesno() -- prompt user to accept yes or no # Usage: yesno [prompt msg] # # Example: # # while ! yesno "sila taip yes"; do # echo "yes ditaip"; # done # yesno() { [ $# -eq 1 ] || return 1; local _prompt="$1"; local _ANS=""; read -p "${_prompt} [yes/no]: " _ANS; while [ "$_ANS" != "yes" ] && [ "$_ANS" != "no" ]; do read -p "Please enter 'yes' or 'no': " _ANS; done; [ "$_ANS" = "yes" ] && return 0; return 1; }