Skip to content

Instantly share code, notes, and snippets.

@rahulinux
Last active September 11, 2016 06:56
Show Gist options
  • Select an option

  • Save rahulinux/6579590 to your computer and use it in GitHub Desktop.

Select an option

Save rahulinux/6579590 to your computer and use it in GitHub Desktop.
User Confirmation function, this function will prompt again if user has hit blank enter,
YesOrNo() {
while :
do
read -p 'Do you want to Continue (yes/no?): ' answer
case "${answer}" in
[yY]|[yY][eE][sS]) exit 0 ;;
[nN]|[nN][oO]) exit 1 ;;
esac
done
}
# Usage:
# if $( YesOrNo ); then
# echo "Ans is yes.. Do something....."
# else
# echo "Ans is No... skip.."
# fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment