Browse Source

ask_yn works perfectly on Arch

main
deicidus 1 year ago
parent
commit
97e3332af9
  1. 12
      spells/cantrips/ask_yn

12
spells/cantrips/ask_yn

@ -18,16 +18,16 @@ stty raw -echo
printf "%s" "$prompt" >&2
while true
do
answer=$(head -c 1)
if [ "$answer" = $'\n' ] || [ "$answer" = $'\r' ]; then
answer=""
break
elif printf "%s" "$answer" | grep -iq "^y\|^n"; then
answer=$(dd bs=1 count=1 2>/dev/null)
if printf "%s" "$answer" | grep -iq "^y\|^n"; then
break
elif [ "$answer" = $'\003' ]; then
elif [ "$(printf "%d" "'$answer'")" -eq 3 ]; then
stty "$old_stty_cfg"
printf '\n'
exit 2
elif [ "$(printf "%d" "'$answer'")" -eq 13 ]; then
answer=""
break
fi
done
stty "$old_stty_cfg" >&2 # Restore original stty configuration

Loading…
Cancel
Save