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 () { yesno () {
printf "%s [yN]" "$1" old_stty_cfg=$(stty -g)
read -r yn stty raw -echo
yn=$(while ! head -c 1 | grep -i '[ny]'; do true; done)
stty "$old_stty_cfg"
case $yn in case $yn in
y ) result=0 ;; y ) result=0 ;;
* ) result=1 ;; * ) result=1 ;;
esac esac
printf "\n"
return $result return $result
} }