Posted to tcl by guardian at Wed Jan 30 10:03:30 GMT 2019view raw

  1. prompt() {
  2. if [[ -t 1 ]]; then
  3. IFS=; while read -rp "$1 (y/n)" -n1 _yn; do
  4. printf '\n'
  5. case $_yn in
  6. [Yy])
  7. return 0;;
  8. [Nn])
  9. return 1;;
  10. esac;
  11. done < /dev/tty
  12. else
  13. case $(cat<<EOF |
  14. wm withdraw .
  15. puts [tk_messageBox -title "Git" -message "$1" -type yesno -icon question]
  16. exit
  17. EOF
  18. /usr/bin/env wish) in
  19. yes)
  20. return 0;;
  21. no)
  22. return 1;;
  23. esac;
  24. fi
  25. }
  26.