I have a symlink that points to some program: git-receive-pack -> git. I want to replace symlink with bash script and then call git as if it was called from symlink before replacement. I tried to call it as git $* but it sees first argument as git and not as git-receive-pack. How to invoke it correctly?
Add a comment
|
1 Answer
I would leave the git-receive-pack symlink alone, instead create a bash function (in ~/.bashrc). Something like this should do the trick:
function git-receive-pack() {
... (do your stuff)
command git-receive-pack $*
}
3 Comments
Carl Norum
You could use
command git-receive-pack to keep your PATH working instead of hardcoding /usr/bin, too.Poma
Will that work for non-interactive shells? Like
git push [email protected]:repo.gitEndrju
Check for
BASH_ENV environment variable, which is used for non-interactive shells. It should be set already. If it's unset, export it from .bash_profile as export BASH_ENV=~/.bashrc. The function will work.