#!/bin/bash

function select_yes_no(){
	local message=$1
	local answer
	local item="yes no all"
	PS3="$message > "
	select answer in ${item}; do
		if [ "${REPLY}" == "q" ]; then
			echo "Exit"
			exit 1
		fi
		if [ -z "$answer" ]; then
			continue
		fi
		case "$answer" in
			[Yy]|[Yy][Ee][Ss])
				echo "1"
				break;
				;;
			[Nn]|[Nn][Oo])
				echo "2"
				break
				;;
			[Aa][Ll][Ll])
				echo "3"
				break
				;;
			*)
				continue
				;;
		esac
	done
}

answer=$(select_yes_no "which ?")
echo "$answer"
