SHARE
TWEET

askyn

tolikpunkoff May 10th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. ask_y_n() #$1 - question
  4. {
  5.     echo -n "$1 [Y/N]: "
  6.     while [ 1 -eq 1 ];do
  7.     read -s -n1
  8.    
  9.     case "$REPLY" in
  10.         [yY])
  11.         echo
  12.         return 0
  13.         ;;
  14.         [nN])
  15.         echo
  16.         return 1
  17.         ;;
  18.     esac
  19.     done
  20. }
  21.  
  22.  
  23. ask_y_n "Run it?"
  24.  
  25. if [ "$?" -eq 0 ];then
  26.     echo "User ask YES!"
  27. else
  28.     echo "User ask NO :("
  29. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top