Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
1  
Igniacio's answer will work, but I have to ask - WHY do you have two different versions of svn installed? –  Shadur Oct 13 '11 at 4:25
add comment

2 Answers

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

share|improve this answer
add comment

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.

share|improve this answer
    
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 6:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.