2

I have two copies of svn on my machine.

  1. /usr/local/bin/svn

  2. /opt/subversion/bin

When I run which svn it states the first is running how can I switch it to the second?

2 Answers2

7

Either create an alias to it in your shell, or put its directory ahead of the other in $PATH.

4

If you want to switch between them on the fly, without changing your $PATH, here's a little pattern I have used over the years, after seeing a coworker use this to good effect. I assume you have a $HOME/bin already, really early in your $PATH. Create the following shell script there,

#/bin/sh
PATH="/usr/local/bin:$PATH" export PATH
exec ${1+"$@"}

called, for example "local". Then you would invoke the version of svn in /usr/local/bin with the call:

$ local svn {whatever other arguments you need}

and just calling svn without this wrapper script will find whatever one is first on your $PATH.

  • I should add that this pattern is most useful if you have two (or more) scripts: for example "stock" and "beta", or "sysv" and "bsd", or "gnu" and "stock". – Gordon Broom Oct 13 '11 at 06:19