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

  1. prompt() {
  2. if false; 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. osascript -e 'repeat until application "Wish" is running'\
  14. -e 'delay 0.1'\
  15. -e 'end repeat'\
  16. -e 'tell application "Wish" to activate'&
  17. case $(cat<<EOF |
  18. wm withdraw .
  19. puts [tk_messageBox -title "Git" -message "$1" -type yesno -icon question]
  20. exit
  21. EOF
  22. /usr/bin/env wish) in
  23. yes)
  24. return 0;;
  25. no)
  26. return 1;;
  27. esac;
  28. fi
  29. }
  30.