title: How to ask for user input in a Git hook?
body: <p>I have been trying to write a simple bash script as a <code>pre-push</code> hook, in which I check for missing test files when pushing Java code.</p>
  
  <p>The problem is: the <code>read</code> command isn't waiting for user input, it proceed as if no input has been entered.</p>
  
  <pre><code>has_java="git diff --stat --cached origin/master | grep \"src\/main.*\.java\""
  has_test="git diff --stat --cached origin/master | grep \"src\/test.*\.java\""
  
  exit_val=0
  
  if eval $has_java; then
      if eval $has_test; then
          :
      else
          echo "*** NO TESTS WERE FOUND WHILE PUSHING JAVA CODE ***"
          read -n1 -p "Do you want to CONTINUE pushing? [Y/n]" doit
          case $doit in  
              n|N) exit_val=1 ;; 
              y|Y) exit_val=0 ;;
              *) exit_val=0 ;;
          esac
      fi
  fi
  </code></pre>