Last active
September 11, 2016 06:56
-
-
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,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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