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 $1
to give it the first one, it has to be the number that were passed in. Here is my code that is in my .bash_profile
:
function git() {
osascript -e 'display alert "before git command"';
git "$@";
osascript -e 'display alert "after git command"';
}
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 "$@"
after the git. From what I understand using "$@"
will dump all of the arguments in. But the first piece of applescript just runs in an infinite loop. What gives?