title: How to stop a bash script from an infinite loop?
body: <p>I have this bash script in my project directory named as shrinkwrap.sh:</p>
  
  <pre><code>update_package_json_changed_files() {
    echo "&gt; changed files"
  
    git diff --cached --name-only | grep -x package.json
  }
  
  update_shrinkwrap_and_at_to_git_index() {
    echo "&gt; Updating npm-shrinkwrap.json and adding to current commit."
  
    npm shrinkwrap
    git add npm-shrinkwrap.json 
  }
  
  if get_package_json_changed_files; then
    update_shrinkwrap_and_at_to_git_index
  fi
  </code></pre>
  
  <p>and I am running this script in package.json as the following:</p>
  
  <pre><code>"scripts": {
    "shrinkwrap": "bin/shrinkwrap.sh"
  }
  </code></pre>
  
  <p>and I installed npm pre-commit in order to execute the script as the following:</p>
  
  <pre><code>"pre-commit": ["shrinkwrap"]
  </code></pre>
  
  <p>when I try to commit, the script goes into an infinte loop. It keeps running, and nothing can stop it. I tried command + C, control + Z. Nothing worked. Did anyone run into this issue before ? why is that happening ?</p>