title: How to use the git diff --cached --name-only --diff-filter=ACM?
body: <p>I trying to write the <code>pre-receive</code> hook to check the committing file. I tried to use the git command <code>git diff --cached --name-only --diff-filter=ACM</code> to get the file committed file list. But I get exception </p>
  
  <pre><code>#!/usr/bin/env ruby
  
  Dir[git diff --cached --name-only --diff-filter=ACM].any? do |f|
   %w|.txt .pdf .dll|.include?(File.extname(f))
     puts "Your commit have exe or dll file. Kindly remove the file an$
   exit 0
  </code></pre>
  
  <p>end </p>
  
  <p>But I get syntax error on 3rd line</p>
  
  <blockquote>
    <p>syntax error, unexpected unary-, expecting keyword_do or '{' or '(' (SyntaxError)</p>
  </blockquote>
  
  <p>As a <code>ruby</code> script beginner, I can not predict why this happening. I need a hand to fix the issue. </p>
  
  <p>Update As per <a href="https://stackoverflow.com/users/6330106/elpiekay">elpiekay</a> guidence.</p>
  
  <pre><code>for line in ARGF.readlines;arr=line.split();oldvalue=arr[0];newvalue=arr‌​[1];refname=arr[2];
  
  Dir[git diff $oldvalue $newvalue --name-only --diff-filter=ACM].any? do |f|
   %w|.txt .pdf .dll|.include?(File.extname(f))
     puts "Your commit have exe or dll file. Kindly remove the file and try again"
   exit 1
   end
  exit 0
  end
  </code></pre>
  
  <p>But Now also I facing the same error in <code>Dir[git diff $oldvalue $newvalue --name-only --diff-filter=ACM].any? do |f|</code> line.</p>