Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function yes_no_abort {
- echo "hi"
- local yn
- while true; do
- read -r -p "[y/n/a]: " yn
- case $yn in
- [Yy]) echo "0"; return 0 ;;
- [Nn]) echo "1"; return 1 ;;
- [Aa]) echo "2"; return 2 ;;
- esac
- done
- }
- echo "Continue? "
- res=$(yes_no_abort)
- if [ $res == 0 ]; then echo "answered yes"; exit 0; fi;
- if [ $res == 1 ]; then echo "answered no"; exit 1; fi;
- if [ $res == 2 ]; then echo "answered abort"; exit 2; fi;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement