title: git pre-commit hook, add file into index
body: <p>I'm trying to write a simple pre-commit hook to check if a file was modified, if so, compress it and add it into the current index, something like this</p>
  
  <pre><code>#!/bin/sh                                                                                                                                                    
  
  # was the file modified?
  mf='git status | grep jquery.detectBrowser.js'
  
  # is the non-compressed file in the staging area?
  if [ $mf != "" ]
  then
    # alert the user
    echo "Javascript file modified, YUI Compressor will begin now."
  
    # go to rhino
    cd $HOME/apps/rhino/yuicompressor-2.4.7/build
  
    # compress my file
    java -jar yuicompressor-2.4.7.jar ~/www/jquery.detectBrowser.js/jquery.detectBrowser.js -o ~/www/jquery.detectBrowser.js/jquery.detectBrowser.min.js
  
    # comeback to the initial directory
    cd -
  
    # add the new file into the index
    git add ~/www/jquery.detectBrowser.js/jquery.detectBrowser.min.js
  fi
  </code></pre>
  
  <p>I have 2 issues, 1 my condition is failing, every time, I must have a typo or something like that, but I can't figure out what it is? This is the error I get back:</p>
  
  <pre><code>[: 23: git: unexpected operator
  </code></pre>
  
  <p>And my second problem is that even if I remove the condition the file is never actually ADDED into the commit, it's modified, but never ADDED.</p>
  
  <p>Thanks,
  Leo</p>