get_char.sh 404 B

12345678910111213141516171819
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. get_char() {
  11. SAVEDSTTY=`stty -g`
  12. stty -echo
  13. stty cbreak
  14. dd if=/dev/tty bs=1 count=1 2> /dev/null
  15. stty -raw
  16. stty echo
  17. stty $SAVEDSTTY
  18. }