title: Wrapping git in other commands via bash function
body: <p>So I want to run a piece of AppleScript before and after my call to git (not the AppleScript below, different AppleScript, but this should get the point through). The issue I am having is that the git command has a variable number of arguments, so I can't just use <code>$1</code> to give it the first one, it has to be the number that were passed in. Here is my code that is in my <code>.bash_profile</code>:</p>
  
  <pre><code>function git() {
      osascript -e 'display alert "before git command"';
      git "$@";
      osascript -e 'display alert "after git command"';
  }
  </code></pre>
  
  <p>The expected result is that the first piece of applescript runs, git runs with whatever amount of arguments has been provided, then the last piece of applescript runs. What really happens is that the first piece of applescript runs over and over indefinitely. I think the issue might be that <code>"$@"</code> after the git. <a href="https://stackoverflow.com/questions/10307280/how-to-define-a-shell-script-with-variable-number-of-arguments">From what I understand</a> using <code>"$@"</code> will dump all of the arguments in. But the first piece of applescript just runs in an infinite loop. What gives?</p>