better yesno function

This commit is contained in:
Samuel Tyler 2019-01-02 14:22:28 +11:00
parent 21688e4fd9
commit 52ace7f214
1 changed files with 4 additions and 3 deletions

7
burrow
View File

@ -563,13 +563,14 @@ edit_config () {
}
yesno () {
printf "%s [yN]" "$1"
read -r yn
old_stty_cfg=$(stty -g)
stty raw -echo
yn=$(while ! head -c 1 | grep -i '[ny]'; do true; done)
stty "$old_stty_cfg"
case $yn in
y ) result=0 ;;
* ) result=1 ;;
esac
printf "\n"
return $result
}