fixing yesno prompt for bsd

This commit is contained in:
James Tomasino 2019-01-21 13:20:35 -05:00
parent 9b6f3daeb1
commit 982eb95372
1 changed files with 19 additions and 22 deletions

19
burrow
View File

@ -567,13 +567,10 @@ edit_config () {
}
yesno () {
printf "%s \\n" "$1"
old_stty_cfg=$(stty -g)
stty raw -echo
yn=$(while ! head -c 1 | grep -i '[ny]'; do true; done)
stty "$old_stty_cfg"
printf "%s " "$1"
read -r yn
case $yn in
y ) result=0 ;;
[Yy]* ) result=0 ;;
* ) result=1 ;;
esac
return $result
@ -591,22 +588,22 @@ quickstart () {
if yesno "Create a phlog? "; then
printf "Phlog directory? (relative to root of gopher site) "
read -r config_dir_phlog
if yesno "Include gophermap"; then
if yesno "Include gophermap? "; then
config_phlog_gophermap=true
else
config_phlog_gophermap=false
fi
if yesno "Include the date in your phlog posts"; then
if yesno "Include the date in your phlog posts? "; then
config_phlog_usedate=true
else
config_phlog_usedate=false
fi
if yesno "Auto-commit to git repo"; then
if yesno "Auto-commit to git repo? "; then
config_git_commit=true
else
config_git_commit=false
fi
if yesno "Auto-push to git remote"; then
if yesno "Auto-push to git remote? "; then
config_git_push=true
else
config_git_push=false
@ -616,7 +613,7 @@ quickstart () {
else
config_autoindent=false
fi
if yesno "Auto-generate phlog RSS"; then
if yesno "Auto-generate phlog RSS? "; then
config_phlog_autorss=true
printf "Name of gopher hole? "
read -r config_gopher_name