title: Git Pre-Commit Hook - No such file or directory
body: <p>I am getting an error when running a pre-commit hook in git, that I can't figure out. This is the script and the error is below.</p>
  
  <pre><code>#!/bin/bash
  
  # Pre-commit hook passing files through jslint and uglify
  
  #ROOT_DIR=$(git rev-parse --show-toplevel)
  JSLINT="/home/john/Projects/node/uglify/node_modules/.bin/jslint --indent 4 --white true -nomen"
  UGLIFYJS="/home/john/Projects/node/uglify/node_modules/.bin/uglifyjs"
  JS_TEMP_EDITOR="/home/john/Projects/node/test/generated/tmp/_combined_editor.js"
  JS_COMBINED_EDITOR="/home/john/Projects/node/test/public/javascripts/editor.min.js"
  
  # Where the editor files are located
  BASE="/home/john/Projects/node/test/public/javascripts/editor/"
  EDITOR=(
      "init.js"
      "utils.js"
      "validation.js"
      "main.js"
      "menu.js"
      "graph.js"
      "settings.js"
      "interview.js"
      "list.js"
      "thumbnail.js"
  )
  
  # go through each javascript file that has changed and run it rhough JSLINT
  for file in $(git diff-index --name-only --diff-filter=ACM --cached HEAD -- | grep -P '\.((js)|(json))$'); do
      if  ! node $JSLINT $file 2&gt;&amp;1 | grep ${file}' is OK.' ; 
      then
          node $JSLINT $file
          exit 1
      fi  
  done
  
  
  # Erase old
  &gt; $JS_TEMP_EDITOR
  &gt; $JS_COMBINED_EDITOR
  
  #run thru the EDITOR and cat the files into one
  for editor_file in ${EDITOR[@]}; do
    cat "$BASE/$editor_file" &gt;&gt; $JS_TEMP_EDITOR
  done
  
  
  # check if  UGLIFYJS gives us an error
  if node $UGLIFYJS $JS_TEMP_EDITOR 2&gt;&amp;1 | grep 'Error' ; 
  then
      exit 1
  else
          # *** THIS IS WHERE THE ERROR IS THROWN
      "node $UGLIFYJS -o $JS_COMBINED_EDITOR $JS_TEMP_EDITOR"
  fi
  
  exit 0
  </code></pre>
  
  <p>This is the error I am getting:</p>
  
  <pre><code>.git/hooks/pre-commit: line 55: node /home/john/Projects/node/uglify/node_modules/.bin/uglifyjs -o /home/john/Projects/node/test/public/javascripts/editor.min.js /home/john/Projects/node/test/generated/tmp/_combined_editor.js: No such file or directory
  </code></pre>
  
  <p>I have changed the permissions of all the files to 777 just for testing, and also checked for CR's anywhere, and I still get the error. The weird part is when <strong>I run the command, from the error given, I get no problem</strong>! </p>
  
  <pre><code>node /home/john/Projects/node/uglify/node_modules/.bin/uglifyjs -o /home/john/Projects/node/test/public/javascripts/editor.min.js /home/john/Projects/node/test/generated/tmp/_combined_editor.js
  </code></pre>
  
  <p>will work just fine.</p>
  
  <p>Hopefully someone can see something that I can't.</p>