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

41
burrow
View File

@ -567,64 +567,61 @@ edit_config () {
} }
yesno () { yesno () {
printf "%s \\n" "$1" printf "%s " "$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 ;; [Yy]* ) result=0 ;;
* ) result=1 ;; * ) result=1 ;;
esac esac
return $result return $result
} }
quickstart () { quickstart () {
printf "Location of your local gopher directory?" printf "Location of your local gopher directory? "
read -r config_dir_gopher read -r config_dir_gopher
printf "Hostname of your gopher server?" printf "Hostname of your gopher server? "
read -r config_gopher_server read -r config_gopher_server
printf "Port of your gopher server?" printf "Port of your gopher server? "
read -r config_gopher_port read -r config_gopher_port
printf "Root directory of your gopher site?" printf "Root directory of your gopher site? "
read -r config_gopher_root read -r config_gopher_root
if yesno "Create a phlog?"; then if yesno "Create a phlog? "; then
printf "Phlog directory? (relative to root of gopher site)" printf "Phlog directory? (relative to root of gopher site) "
read -r config_dir_phlog read -r config_dir_phlog
if yesno "Include gophermap"; then if yesno "Include gophermap? "; then
config_phlog_gophermap=true config_phlog_gophermap=true
else else
config_phlog_gophermap=false config_phlog_gophermap=false
fi 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 config_phlog_usedate=true
else else
config_phlog_usedate=false config_phlog_usedate=false
fi fi
if yesno "Auto-commit to git repo"; then if yesno "Auto-commit to git repo? "; then
config_git_commit=true config_git_commit=true
else else
config_git_commit=false config_git_commit=false
fi fi
if yesno "Auto-push to git remote"; then if yesno "Auto-push to git remote? "; then
config_git_push=true config_git_push=true
else else
config_git_push=false config_git_push=false
fi fi
if yesno "Auto-indent posts?"; then if yesno "Auto-indent posts? "; then
config_autoindent=true config_autoindent=true
else else
config_autoindent=false config_autoindent=false
fi fi
if yesno "Auto-generate phlog RSS"; then if yesno "Auto-generate phlog RSS? "; then
config_phlog_autorss=true config_phlog_autorss=true
printf "Name of gopher hole?" printf "Name of gopher hole? "
read -r config_gopher_name read -r config_gopher_name
printf "Description of gopher hole?" printf "Description of gopher hole? "
read -r config_gopher_desc read -r config_gopher_desc
printf "RSS filename?" printf "RSS filename? "
read -r config_file_rss read -r config_file_rss
printf "Number of RSS entries?" printf "Number of RSS entries? "
read -r config_rss_num_entries read -r config_rss_num_entries
else else
config_phlog_autorss=false config_phlog_autorss=false